同一源码,在本地可以,在服务器上面执行不了。解决方法

WBOY
Release: 2016-06-13 13:42:35
Original
1317 people have browsed it

同一源码,在本地可以,在服务器上面执行不了。
我写了一个ajax请求,我在本地测式是好好的,但是我放在服务器上面执行就不行了。也查不出原因来?

你们曾经有这种情况没有。

ajax

JScript code
<!--

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);    
        }
    });    
}

Copy after login

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php require_once("config.php");
$news= new Db_Base();
mysql_query("set names utf8");    
$sql=" SELECT paytype FROM  `nav` WHERE  `id` = ".$_GET['id']." LIMIT 1";
$news->Db_Query($sql);
$row=$news->Db_Fetch_Array();
if($row){
    echo json_decode($row['paytype']);
}else{
    die(0);
}
?>

Copy after login


服务端:



------解决方案--------------------
首先确认服务器是否支持json. 还有不是应该用 json_encode 吗?
------解决方案--------------------
数据库是不是对应上了,用户名密码表名啥的
------解决方案--------------------
url='ajaxlist.php';路径的问题吧。用绝对的试试
------解决方案--------------------
使用var_dump输出后台数据,firebug等看看后台传递的数据格式对不对,是否bom头、编码等ajax传统问题?
------解决方案--------------------
探讨

使用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},
不知是否手误

单独执行服务器端程序,检查返回结果是否正常
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!