Sending http request to a remote server in sencha

Sending http request to a remote server in sencha:

Ext.Ajax.request({
url: 'ajax_data/simple.json',
success: function(response, opts) {
console.dir(Ext.decode(response.responseText););
},
failure: function(response, opts) {
console.log('request failed : ' + response.status);
}
});

where,

url: The URL to which to send the request, or a function to call which returns a URL string

params:  parameters to the request

 

callback :  The function to be called upon receipt of the HTTP response. The callback is called regardless of success or failure and is passed the following parameters:

options: The parameter to the request call.

success: True if the request succeeded.

response: The XMLHttpRequest object containing the response data.

 

Ext.Ajax.request({ url:'ajax_demo/sample.json', success:function(response, opts){var obj =Ext.decode(response.responseText); console.dir(obj);}, failure:function(response, opts){ console.log('server-side failure with status code '+ response.status);}});

Notes on mod_rewrite for Apache

Apache’s mod_rewrite document, calls this module as “Swiss Army Knife of URL manipulation!”

 

mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs. Incoming URLs are checked against a series of rules. The rules contain a regular expression to detect a particular pattern. If the pattern is found in the URL, and the proper conditions are met, the pattern is replaced with a provided substitution string or action. This process continues until there are no more rules left or the process is explicitly told to stop.

 

Fig: mod_rewrite control flow.

 

Advantages

  1. mod_rewrite can be used to transform long and complex urls into user friendly or short urls.

    For eg. http://myrurl.php/customer.php?name=shan&id=4562&aadr=561

    Above url can be converted to a more user friendly one as,

    http://myurl.php/customer/shan

     

  2. Security enhancement.

    Consider the above example a potential hacker can try out different urls to hack into the system by giving different parameters and values passed to customer.php, using mod_rewrite we can prevent such threats.

     

    mod_rewrite can be enabled by uncommenting the line,

    LoadModule rewrite_module modules/mod\_rewrite.so

    in apache configuration file httpd.conf.