jquery mobile ajax跨域

   在android中webview中调用的页面中不能使用jquery中的$.get()和$.post()方法进行ajax访问非本地资源。php

  使用$.getJSON(url+"callbak=?",function(data){});能够实现跨域访问,并且要在usrl后加入“callback=?”,jQuery 将自动替换 ? 为正确的函数名,以执行回调函数。jquery

例子:android

android:web

   $.getJSON('http://xxxxx.com/getmessage.php?callback=?',function(data){  //回调函数});ajax


php:json

echo $_REQUEST['callback']."(".json_encode($data).")";跨域

相关文章
相关标签/搜索