Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在使用ajax重新修改数据时,会收到一条错误消息_Php_Javascript_Ajax_X Cart - Fatal编程技术网

Php 在使用ajax重新修改数据时,会收到一条错误消息

Php 在使用ajax重新修改数据时,会收到一条错误消息,php,javascript,ajax,x-cart,Php,Javascript,Ajax,X Cart,我通过ajax发布我的值,并使用响应显示详细信息。我在检索数据时遇到了问题。但我不知道哪里出错了,那么这就是频繁显示的错误 “使用XMLHTTP时出现问题:\n” 这是我的密码 var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e) { // Internet Explorer 6+ try { xmlHttp =

我通过ajax发布我的值,并使用响应显示详细信息。我在检索数据时遇到了问题。但我不知道哪里出错了,那么这就是频繁显示的错误 “使用XMLHTTP时出现问题:\n”

这是我的密码

var xmlHttp;

try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
} catch (e) {
    // Internet Explorer 6+
    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        // Internet Eplorer 5
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            alert("Your browser does not support AJAX. Download a newer browser to view this page.");
            return false;
        }
    }
}

// insert server response into HTML element
xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            MM_check_session(xmlHttp.responseText);
            var b_gc = document.getElementById(insert).value;
            document.getElementById(insert).value = xmlHttp.responseText;
            var shippingid = getCheckedValue('checkout_form', 'shippingid');
            closeMessage();
            MM_calc_shipping(shippingid);
            if (b_gc == xmlHttp.responseText) {
                MM_register();
            } else {
                error = 1;
                document.getElementById('payment_error').innerHTML = xmlHttp.responseText;
                document.getElementById(insert).value = '';
            }
        } else {
            closeMessage();
            alert("We can't process your request.Please refresh(reload) the page to proceed further:\n"
                    + xmlHttp.statusText);
        }

    }
}
displayStaticMessage(
        '<img src=' + config_MM_loader_image_path + ' alt=\'loading...Please wait\'>',
        false);

xmlHttp.open("POST", serverScript, true);
xmlHttp.setRequestHeader('Content-type',
'application/x-www-form-urlencoded');
xmlHttp.setRequestHeader('Content-length', parameters.length);
xmlHttp.setRequestHeader('Connection', 'close');
xmlHttp.send(parameters);
var-xmlHttp;
试一试{
//Firefox、Opera 8.0+、Safari
xmlHttp=新的XMLHttpRequest();
}捕获(e){
//Internet Explorer 6+
试一试{
xmlHttp=新的ActiveXObject(“Msxml2.xmlHttp”);
}捕获(e){
//互联网Eplorer 5
试一试{
xmlHttp=新的ActiveXObject(“Microsoft.xmlHttp”);
}捕获(e){
警报(“您的浏览器不支持AJAX。请下载较新的浏览器以查看此页面。”);
返回false;
}
}
}
//将服务器响应插入HTML元素
xmlHttp.onreadystatechange=函数(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
MM_检查_会话(xmlHttp.responseText);
var b_gc=document.getElementById(insert).value;
document.getElementById(insert).value=xmlHttp.responseText;
var shippingid=getCheckedValue('checkout_form','shippingid');
closeMessage();
MM_计算装运(装运ID);
if(b_gc==xmlHttp.responseText){
MM_寄存器();
}否则{
误差=1;
document.getElementById('payment_error')。innerHTML=xmlHttp.responseText;
document.getElementById(insert).value='';
}
}否则{
closeMessage();
警报(“我们无法处理您的请求。请刷新(重新加载)页面以继续:\n”
+xmlHttp.statusText);
}
}
}
显示静态消息(
'',
假);
open(“POST”,serverScript,true);
setRequestHeader('Content-type',
‘application/x-www-form-urlencoded’;
setRequestHeader('Content-length',parameters.length);
setRequestHeader('Connection','close');
send(参数);

任何帮助

您似乎被错误地标记为php。您还考虑过jQuery在使用ajax时的易用性

至于您的问题,您能否将代码发布在ajax请求的页面上,因为这里的代码看起来不错

编辑: 服务器脚本设置在哪里? 是否更改要调用的ajax页面的serverScript?

在您的代码中找不到产生上述错误消息的地方(“使用XMLHTTP时出现问题:\n”)。
var xmlHttp;

try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
} catch (e) {
    // Internet Explorer 6+
    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        // Internet Eplorer 5
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            alert("Your browser does not support AJAX. Download a newer browser to view this page.");
            return false;
        }
    }
}

// insert server response into HTML element
xmlHttp.onreadystatechange = function() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            MM_check_session(xmlHttp.responseText);
            var b_gc = document.getElementById(insert).value;
            document.getElementById(insert).value = xmlHttp.responseText;
            var shippingid = getCheckedValue('checkout_form', 'shippingid');
            closeMessage();
            MM_calc_shipping(shippingid);
            if (b_gc == xmlHttp.responseText) {
                MM_register();
            } else {
                error = 1;
                document.getElementById('payment_error').innerHTML = xmlHttp.responseText;
                document.getElementById(insert).value = '';
            }
        } else {
            closeMessage();
            alert("We can't process your request.Please refresh(reload) the page to proceed further:\n"
                    + xmlHttp.statusText);
        }

    }
}
displayStaticMessage(
        '<img src=' + config_MM_loader_image_path + ' alt=\'loading...Please wait\'>',
        false);

xmlHttp.open("POST", serverScript, true);
xmlHttp.setRequestHeader('Content-type',
'application/x-www-form-urlencoded');
xmlHttp.setRequestHeader('Content-length', parameters.length);
xmlHttp.setRequestHeader('Connection', 'close');
xmlHttp.send(parameters);