jquery - Phonegap AJAX call fails -


i'm trying simple phonegap app communicate server.

this javascript:

<script src="js/jquery.min.js" ></script>     <script>         $.ajax({             url: 'http://www.drimmit.com/test',             datatype: 'jsonp',             jsonp: 'jsoncallback',             timeout: 5000,             success: function(data, status){                 //data loaded                 alert(data);             },             error: function(){                 //error loading data                 alert('no data');             }         });     </script> 

i've whitelisted domain in config.xml:

<access origin="http://www.drimmit.com" subdomains="true"/> 

on server, i'm doing simple echo statement.

<?php header('content-type: application/json'); echo 'hello server';  ?> 

in end, popup (ios) saying "no data", meaning failed.

you have mentioned request type jsonp, server rendering json, hence issue, if u remove "jsonp: 'jsoncallback'" statement ajax call , should work fine, replace datatype:'jsonp' datatype:'json'.

ps - jsonp used if making cross doamin requests, in phonegap not required have whitelisted domain.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -