android - PhoneGap AJAX request not working -


i using latest phonegap version, , doing ajax calls.

$.ajax({             type      : 'post',             url       : 'http://example.com/path api',              data      : {d1: v1, d2: v2},             datatype  : 'json',             success   : function(data) {                            console.log(data);                         },             error     : function(){                             alert('error');                         } });  

when test app on desktop browser or mobile phonegap developer app, works fine, after building application (.apk), ajax requests not work , fall on failure rather success. have done configurations mentioned include:

<access origin="*" />  <plugin name="cordova-plugin-whitelist" version="1" />     <allow-navigation href="*" />     <allow-intent href="http://*/*" />     <allow-intent href="https://*/*" /> 

also added content-security-policy meta tags in html , pointed domain api located:

<meta http-equiv="content-security-policy" content="connect-src 'self' http://example.com/"> 

i using phonegap online build service build app. need have done fixes find no success yet.

@nabeel, in luck. finishing blog post on whitelist

change csp follow. should trick

<meta http-equiv="content-security-policy"            content="default-src *;                     style-src 'self' 'unsafe-inline' 'unsafe-eval';                     script-src 'self' 'unsafe-inline' 'unsafe-eval';"> 

if working ios9, you'll need add apple's ats. read further on document details on that.

best of luck


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -