I am working on mobile web app using sencha touch 2.1. Currently I am making a login system. Do to this I am sending ajax request to remote server from my local machine with username and password in it. But I am keep getting this error
XMLHttpRequest cannot load http://something.com/login.php?_dc=1362983327250. Origin http://dev.vclouds.com is not allowed by Access-Control-Allow-Origin.
In above error http://dev.vclouds.com
is my localhost
. I set it up in my apache config this way.
Here is my code for ajax request
Ext.Ajax.request({
url: 'http://something.com/beta/webservice/login.php',
method: 'post',
params: {
user_name: username,
user_password: password
},
success: function (response) {
var loginResponse = Ext.JSON.decode(response.responseText);
console.log(loginResponse);
if(loginResponse.success === "true") {
me.sessionToken = loginResponse.sessionToken;
me.signInSuccess();
} else {
me.signInFailure(loginResponse.message);
}
},
failure: function (response) {
me.sessionToken = null;
me.signInFailure('Login failed');
},
callback: function (opts, success, response) {
console.log('callback');
console.log(opts);
console.log(success);
console.log(response);
}
});
How can I solve this problem?
UPDATE
I also tried JsonP as follow
Ext.data.JsonP.request({ //<-- line 35
url: 'http://something.com/beta/webservice/login.php',
callbackKey: 'callback',
//method: 'post',
params: {
user_name: username,
user_password: password
},
callback: function (opts, success, response) {
console.log('callback');
console.log(opts);
console.log(success);
console.log(response);
}
});
But I am getting this error
Uncaught TypeError: Cannot call method 'request' of undefined Login.js:35