Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.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
Javascript 获取错误无法加载ajax_Javascript_Php_Jquery_Ajax_Json - Fatal编程技术网

Javascript 获取错误无法加载ajax

Javascript 获取错误无法加载ajax,javascript,php,jquery,ajax,json,Javascript,Php,Jquery,Ajax,Json,这是我整个脚本的一部分(整个脚本有点长,就是这样)。它工作得很好,但突然它停止了工作,我在控制台中得到一个错误,说无法处理ajax $.ajax({ type: 'post', url: 'test2.php', dataType: 'json', data: { txt: txtbox, hidden: hiddenTxt }, cache: false, success: function(returnd

这是我整个脚本的一部分(整个脚本有点长,就是这样)。它工作得很好,但突然它停止了工作,我在控制台中得到一个错误,说
无法处理ajax

$.ajax({
    type: 'post',
    url: 'test2.php',
    dataType: 'json',
    data: {
        txt: txtbox,
        hidden: hiddenTxt
    },
    cache: false,
    success: function(returndata) {
        $('#first').html(returndata[0]);
        $('#second').html(returndata[1]);
        $('#third').html(returndata[2]);

        $('#fourth').html('<img src="' + returndata[3] + '" height="125" width="125">')
        console.log(returndata);

        $("#walkaway").show();
        $("#submitamt").show();
    },
    error: function() {
        console.error('Failed to process ajax !');
    }

});
$.ajax({
键入:“post”,
url:'test2.php',
数据类型:“json”,
数据:{
txt:txtbox,
隐藏:hiddenTxt
},
cache:false,
成功:函数(返回数据){
$('#first').html(returndata[0]);
$('#second').html(returndata[1]);
$('#third').html(returndata[2]);
$('#第四').html('')
console.log(返回数据);
$(“#走开”).show();
$(“#submitamt”).show();
},
错误:函数(){
console.error('Failed to process ajax!');
}
});

谁能告诉我问题出在哪里。

所有点都指向Web服务器。当你发帖子时,服务器返回了一个错误代码。我认为你缺少了一个
在第四个…@orestiss:这在javascript中并不重要。我猜问题来自服务器端。@Turrican我如何更正它
test2。php
没有生成有效的JSON字符串。手动测试时,复制它并在联机JSON解析器上验证输出。最好在php上使用
JSON.stringify()
。如果是,这意味着它可能会生成空响应。所有指向Web服务器。当你发帖子时,服务器返回了一个错误代码。我认为你缺少了一个
在第四个…@orestiss:这在javascript中并不重要。我猜问题来自服务器端。@Turrican我如何更正它
test2。php
没有生成有效的JSON字符串。手动测试时,复制它并在联机JSON解析器上验证输出。最好在php上使用
JSON.stringify()
。如果是,这意味着它可能会生成空响应。