同一源码,在本地可以,在服务器上面执行不了。
我写了一个ajax请求,我在本地测式是好好的,但是我放在服务器上面执行就不行了。也查不出原因来?
你们曾经有这种情况没有。
ajax
- JScript code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function showList(id){ url='ajaxlist.php'; $.get(url,{id:id}, function (e){ if(e==0){ $("#info").html("无支付信息"); } else{ $("#info").html(e); } }); }
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phprequire_once("config.php");$news= new Db_Base();mysql_query("set names utf8"); $sql=" SELECT paytype FROM `nav` WHERE `id` = ".$_GET['id']." LIMIT 1";$news<p style="color:transparent">。本文来源gao!%daima.com搞$代*!码网1</p><cite>搞代gaodaima码</cite>->Db_Query($sql);$row=$news->Db_Fetch_Array();if($row){ echo json_decode($row['paytype']);}else{ die(0);}?>
服务端:
——解决方案——————–
首先确认服务器是否支持json. 还有不是应该用 json_encode 吗?
——解决方案——————–
数据库是不是对应上了,用户名密码表名啥的
——解决方案——————–
url=’ajaxlist.php’;路径的问题吧。用绝对的试试
——解决方案——————–
使用var_dump输出后台数据,firebug等看看后台传递的数据格式对不对,是否bom头、编码等ajax传统问题?
——解决方案——————–
——解决方案——————–
$.get(url,{id:id},
function (e){
if(e==0){
$(“#info”).html(“无支付信息”);
} else{
$(“#info”).html(e);
}
}); 是不是你的get方式type应该是json传送吧。
——解决方案——————–
$.get(url,{id:id}, ???
$.get(url,{‘id’:id},
不知是否手误
单独执行服务器端程序,检查返回结果是否正常