首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

jquery跨域失败

2012-02-24 
jquery跨域失败求助 - Web 开发 / Ajaxjquery跨域失败求助在firebug控制台中输入$.getJSON(http://my-dem

jquery跨域失败求助 - Web 开发 / Ajax
jquery跨域失败求助

在firebug控制台中输入
$.getJSON("http://my-demo.ifreeweb.net/question/theme_json.php",{},function(data){alert(data.themes)})
返回206错误,为什么无法跨域?

http://my-demo.ifreeweb.net/question/theme_json.php代码

PHP code
<?php    $themes=array(        "themes"=>array("hello","world")    );    $json=json_encode($themes);    echo $json;?>


[解决办法]
用 jsonp
HTML code
$.ajax{   url: "http://my-demo.ifreeweb.net/question/theme_json.php",   cache: false,   dataType: 'jsonp',   jsonp: 'myfun'}function myfun(data){  alert(data.themes);} 

热点排行