Search code examples
xmlsencha-touchajax.request

Getting communication failure while sending xml request from sencha touch?


I am trying to send XML data using Ajax.request from Sencha Touch as shown below:

var request = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?><a>....</a>";
Ext.Ajax.request({
                url: 'http://192.168.xxx.xxx:8992',
                method: 'POST',
                headers: {'Content-Type': 'text/xml'},
                xmlData: request,
                success: function (responseData, opt) {
                    console.log(responseData.responseText);
                },
                failure: function (responseData, opt) {
                    console.log('ajax:failure:status,statusText='+ responseData.status+','+responseData.statusText);
                }
            });

But i am encountering the failure and has

responseData.status = 0

responseData.statusText = communication failure

I have also use HTTPrequester ( https://addons.mozilla.org/en-us/fir...httprequester/ ) to test XML request messages and it works and return expected XML response.

Can any one help me what might the reason for this error while using Ext.Ajax.request and how to solve?

Thanks in advance.


Solution

  • I got it.

    This issue is related to cross-domain and currently been able to run it without error by disabling cross-domain security check in Google Chrome.

    Close all google chrome browsers and run following command

    google-chrome --disable-web-security
    

    You can also solve it by setting CORS on the server.