Ajax call on phonegap does not send request

I pull my hair on it.

I have a jquery-ajax call to my server that works in my browser, it works on my device when I connect to my local proxy server for http sniffing, but just hangs when it disconnects from my proxy server on Wi -Fi or on a cellular network.

I installed phonegap config.xml to resolve my domain. A request is a receipt on the server, as well as an ajax call. You will notice this is jsonP.

Calling direct jquery, I will still send the code. The api object is a custom object that I created to store application functionality.

var dfd = $.ajax({
    url: myurl, // I've confirmed the url, but prefer to keep it private
    data: {
        ApplicationID: api.applicationID,
        DeviceID: api.device.uuid(),
        OSVersion: api.device.version(),
        DeviceVersion: api.device.platform(),
        Lat: lat,
        Lng: lng,
        Bearing: bearing
    },
    dataType: "jsonp",
    timeout: 30000
})
.fail(function (event, jqXHR, ajaxSettings, thrownError) {
    console.error(jqXHR);
});

I tried this answer closest to my problem, but it doesn't seem to work. JQuery ajax phone query not working

-, ? ?

EDIT: , -, ajax, , .

+5
3

, . - , AMD. , , .

0

json,

$.getJSON("http://www.example.com?jsoncallback=?",
    function(data){ ... }

jsoncallback. , , jquery , , . .

json-builder , jsoncallback :

$return =  $_GET["jsoncallback"].'({"title" : "test", "author" : "someone"});
0

Your problem may not be, as you mentioned, a cross-domain. Does your server log any requests? I have a similar problem with the second (same) query after binding it to index.html, the first query is working fine. I found information that this could be a phone call error.

0
source

All Articles