javascript - AJAX post request working in browser, not on Phonegap App -
a simple ajax request failing when test using phonegap app on ios10.
code follows (works in browser):
if($.trim(firstname).length > 0 & $.trim(email).length > 0 & $.trim(password).length > 0) { console.log("input checked"); $.support.cors = true; $.ajax({ type: "post", url: "http://my-server.com/signup.php", data: datastring, crossdomain: true, cache: false, beforesend: function(data) { console.log("connecting server"); }, //display success/fail message - put in data on server success: function(data, textstring, xhr) { if(data == "success") { localstorage.login = "true"; localstorage.email = email; mainview.router.loadpage("swipe.html"); } else if(data == 'exist') { myapp.alert("account exists", "login failed"); } }, error: function(xhr, ajaxoptions, errorthrown) { console.log("error msg: "); console.log(xhr); console.log(errorthrown); myapp.alert("unknown error, please try again", "login failed"); }, complete: function(data) { if(data.readystate == "0") { console.log("unsent"); } else if(data.readystate == "4") { console.log("done"); } } }); } return false; } i have config.xml file set outlined in many previous answers:
<plugin name="cordova-plugin-whitelist" /> <access origin="http://my-server.com" /> etc... obviously disabling apple's app transport security not going possible not building app, testing on phonegap server , phonegap app.
but possibly ats preventing ajax requests other domains phonegap app itself? suppose require phonegap allow access domains, isn't allowed on app store!
that best guess happening. ideas or workarounds?
the internet solution new ios apps move backend https...
Comments
Post a Comment