I am trying to call a webservice. I want that if i am not getting response from web service in 10 sec then the service call should fail and show the error message in .error section. I tried passing timeout in http call but that is not working for mobile phones. My service call is like this-
$http({
method: "POST",
url: url,
*timout:10000,*
headers: {
'Content-Type': "application/x-www-form-urlencoded",
'Encoding':"UTF-8",
'devicemetadata':devicemetadata
},
data: inputData,
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}
})
.success(function(response){
console.log("loginServiceSuccess:"+JSON.stringify(response));
def.resolve(response);
})
.error(function(msg){
console.log("loginServiceFailure"+msg);
def.reject(msg);
});
Timeout is not working for mobile phones. I want that if service does not give response in 10sec .error block should be executed...any solution?