The Blog

PHP

Slick way to deal with 301 and 302 from Ajax call.

Posted on

On the Server side response with similar code:

header('HTTP/1.0 278 Ok');
echo json_encode(array('redirect' => "/"));
exit;

In JQuery bind AjaxSuccess to this function. Somewhere in a global header or layout page, so it get accesses from all pages.

$('body').bind('ajaxSuccess',function(event, request, settings){
if (request.status == 278){
jsonresponse = $.parseJSON(request.responseText);
$('form').dirtyForms('setClean');
window.location.href = jsonresponse.redirect;
}
});
Posted in PHP Leave a comment

Executing SQL directly in Symfony2 Doctrine

Posted on

Ok, so I’m moving project from non framework PHP to Symfony2, and it goes very nice, except of Doctrine, I’m sure it’s me. I’ve been using MySQL for last 8 years and DQL vs SQL to me feels like i.e. taking snowboard for the first time, after skiing for 30 years. What I do after 30 min. of trying. I’m going back to rental place and I switch to skis. Below one can find skis.
Read More

Posted in Frameworks, PHP, Symfony3 29 Comments

Symfony 2 and Plesk 10 on CenOS 5

Posted on

Here it goes:

In order to change default document root for a domain hosted in a plesk control panel we need to create vhost.conf file in the directory in which http.include for the domain resides. Directly changing the document root entry in httpd.include causes the modification to be overwritten with default entry since plesk overwrites entries in configuration files with database entries
Entries to be put in the vhost.conf follows
Read More

Posted in PHP, PLESK Leave a comment
« Previous PageNext Page »