Browser send request to server but from simulator not send


#1

Hell Sir,
I have add ios platform. When is use browser it send request to server. But when i use from simulation from xcode it do does send request to server.
Here is sample little programe
$scope.doSubmit = function(){
$ionicLoading.show({
template: ‘Please Wait…’
});
$http({
method: ‘POST’,
url: ‘http://202.40.190.14:8084/testMac/TestServeetSv’,
params: {name:“Enamul Haque”},
// params: {cusCode:cusCode},
//type:‘JSON’,
headers : { ‘Content-Type’: ‘application/json’ }
}).success(function(data, status, headers, config) {
$ionicLoading.hide();
$ionicPopup.alert({
title:‘Success’,
//template:‘From date’
})
//alert($rootScope.responseArr.toString);
}).error(function(data, status, headers, config) {
$ionicLoading.hide();
$ionicPopup.alert({
title:‘Data :’+data+‘status :’+status+‘headers :’+headers+‘config :’+config,
//template:‘From date’
})
});
}

here is image from simulator

Note :It is working in adobe phonegap buld.
Please Help me…


#2

Have you configured whitelist plugin? Have you correctly setup CORS both on mobile and server side?


#3

Hello gmarziou

I am using java servlet. I am using it in android apps. I am using for post request and get response like that
System.out.println("response = " + request.getParameter(“name”));

       response.addHeader("Access-Control-Allow-Origin", "*");
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
       // response.getWriter().print(json.toString());
        response.getWriter().flush();

#4

Thats for the server and it is usually done through a servlet filter not in servlet itself.

Client side has some work to do, search the forum.