Telephone service for Windows Phone jQuery ajax callback not running

I have a problem with Phonegap for Windows Phone and jQuery.

I have an Ajax request to a remote server, but the success callback fails even if the server answers with code 200 (I see a request on the access_log server). The error callback also fails.

The code

$.support.cors = true; $.mobile.allowCrossDomainPages = true; $.ajax({ url: 'http://example.com', data: { foo: 'bar' }, cache: false, dataType: 'json', success: function (data) { console.log(data); } }); 

Any idea?

+2
source share
3 answers

This seems to be a known issue of local implementation of XHR laying in the telephone gap 1.3.0. You can switch to the previous version or comment on everything in phonegap-1.3.0.js, starting from line 3551 to the end of the file

 //(function(win,doc){ // // doc.addEventListener("DOMContentLoaded",function() // { // ...... // if(!docDomain || docDomain.length == 0) // { // //console.log("adding our own Local XHR shim "); // var aliasXHR = win.XMLHttpRequest; // // win.XMLHttpRequest = function(){}; // // var UNSENT = 0; // ...... // // //})(window,document); 

EDIT PhoneGap 1.4.0rc1 is done

https://github.com/purplecabbage/callback-windows-phone

Changes include fixes for XHR for local files, + fixes to correctly use the functions of a single / multi-page jQM application.

0
source

I have the same problem, but neither this advice nor the new version of the telephone conversation helped. With phonegap 1.4.0, I now always get a callback.

+1
source

If you are using jQuery Mobile, you need to set the following to true:

$. support.cors and $ .mobile.allowCrossDomainPages

jQuery expects all js code to be run in a normal browser environment where cross-domain requests are not allowed. I think they came up with this specifically for PhoneGap.

Check out jQuery Mobile Docs

+1
source

Source: https://habr.com/ru/post/1492814/


All Articles