Recent Posts

Showing posts with label request. Show all posts
Showing posts with label request. Show all posts

Detecting PHP request type (GET, POST, PUT or DELETE)

To detect the PHP request type this is doing by using:

$_SERVER['REQUEST_METHOD']
For more details please see the documentation for the $_SERVER variable.

How to: Perform an AJAX Synchronous request

From the Jquery docs: you specify the async option to be false to get a synchronous Ajax request. Then your callback can set some data before your mother function proceeds.

Here's what your code would look like if changed as suggested:

beforecreate: function(node,targetNode,type,to) {
    jQuery.ajax({
         url:    'http://example.com/catalog/create/' 
                  + targetNode.id 
                  + '?name=' 
                  + encode(to.inp[0].value),
         success: function(result) {
                      if(result.isOk == false)
                          alert(result.message);
                  },
         async:   false
    });          
}