$http post work on browser but not device?(form submit)

Jquery method also work on browser but not work on real device.
I had add the related plugins such as file, network information but still not work.
Anyone has same problem?

Have you checked to see if there are any error messages?

$http returns a promise where you can handle an error.

$http.post(...).then(function(){
//success
},function(){
//error
})
}).success(function (data, status, headers, config) {

					$scope.hello = {name: "ok"};
			}).error(function (data, status, headers, config) {

					$scope.hello = {name: "not ok"};

				        alert(data);
				        alert(status);
				        alert(headers);
				        alert(config);
			});

Here is the result of error message:
data: the serve IP address
status: 0
headers:

function (name) {

if (!headersObj) headersObj =  parseHeaders(headers);

if (name) {

  return headersObj[lowercase(name)] || null;

}

return headersObj;

}

config: [object Object]

is it the cross domain problem?

Have you set up the site as whitelisted in your config.xml?

For example:

<access origin="http://google.com" />

http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html

Thanks. Andrewmcgivery.

I solved the problem by adding this on php to allow other domain access.

header(“Access-Control-Allow-Origin: *”);

i have same problem with $http.post(url,data).then(function(result){//success},function(error){//error});
it shows on browser and it works on ionic run -l -c – device but it does not work on ionic run – device and i am using jee app server(tomcat) but it shows 403 on error status

just remove filter part from the web.xml . it works like a charm

1 Like