Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.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函数的JavaScript Ajax调用不起作用_Javascript_Ajax - Fatal编程技术网

对PHP函数的JavaScript Ajax调用不起作用

对PHP函数的JavaScript Ajax调用不起作用,javascript,ajax,Javascript,Ajax,下面是javascript函数的代码,在删除语法错误后调用该函数。错误消息为goen,但ajax调用不起作用 <script type="text/javascript"> function updatedb(counterid,table,team,feature,scenario){ var DefectNumber = parseInt(counterid); alert(document.getElementById(Defect

下面是javascript函数的代码,在删除语法错误后调用该函数。错误消息为goen,但ajax调用不起作用

 <script type="text/javascript">
    function updatedb(counterid,table,team,feature,scenario){

        var DefectNumber = parseInt(counterid);

        alert(document.getElementById(DefectNumber).textContent);
        //document.getElementById("RunFilters").rows[5].cells[0].innerHTML          
        $.ajax({type:'POST',  url:'updateDB.php',data: 'postdefctnumber='+DefectNumber+'&posttable='+table+'&postteam='+team+'&postfeature='+feature+'&postscenario='+scenario } , 
            function(data){
                $('#resultdi').html(data);
            }

        );

    }


 </script>

函数updatedb(计数器ID、表、团队、功能、场景){
var-DefectNumber=parseInt(计数器ID);
警报(document.getElementById(缺陷编号).textContent);
//document.getElementById(“RunFilters”).rows[5]。单元格[0]。innerHTML
$.ajax({type:'POST',url:'updateDB.php',data:'postdefctnumber='+DefectNumber+'&posttable='+table+'&postteam='+team+'&postfeature='+feature+'&postscapenario='+scenario},
功能(数据){
$('#resultdi').html(数据);
}
);
}

您在逗号前的这一行末尾留下了“}”:

$.ajax({type:'POST',  url:'updateDB.php',data: 'postdefctnumber='+DefectNumber+'&posttable='+table+'&postteam='+team+'&postfeature='+feature+'&postscenario='+scenario  },
数据属性也应该是一个对象:

data: {query: 'postdefctnumber='+DefectNumber+'&posttable='+table+'&postteam='+team+'&postfeature='+feature+'&postscenario='+scenario}
正如“从jQuery 3.0开始删除了弃用通知:jqXHR.success()、jqXHR.error()和jqXHR.complete()回调。您可以使用jqXHR.done()、jqXHR.fail()和jqXHR.always()来代替。”在中找到的,您不应该使用“success”回调

请尝试使用以下示例:

$.ajax( "example.php" )
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});

您在这一行末尾的逗号前留下了“}”:

$.ajax({type:'POST',  url:'updateDB.php',data: 'postdefctnumber='+DefectNumber+'&posttable='+table+'&postteam='+team+'&postfeature='+feature+'&postscenario='+scenario  },
数据属性也应该是一个对象:

data: {query: 'postdefctnumber='+DefectNumber+'&posttable='+table+'&postteam='+team+'&postfeature='+feature+'&postscenario='+scenario}
正如“从jQuery 3.0开始删除了弃用通知:jqXHR.success()、jqXHR.error()和jqXHR.complete()回调。您可以使用jqXHR.done()、jqXHR.fail()和jqXHR.always()来代替。”在中找到的,您不应该使用“success”回调

请尝试使用以下示例:

$.ajax( "example.php" )
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});

@如果我错了,雷努凯什会纠正我,但我认为
函数(数据){$('#resultdi').html(数据)}
行应该是
函数(数据){$('#resultdi').html(数据)}
加上一个小的
f
,谢谢你的纠正,错误现在已解决,但AJAX调用仍然不起作用。我无法看到此工作函数(数据){$('#resultdi').html(数据);}@ickyrr是的,函数词应该是带有小写字母fThanks的函数以进行更正,我已经更新了控制台,现在控制台中没有错误,但ajax cal仍然没有working@Renukesh如果我错了,请纠正我,但我认为
Function(data){$('resultdi').html(data)}
行应该是
Function(data){$('resultdi').html(data);}
带有一个小的
f
。感谢您的更正,错误现在已经解决,但AJAX调用仍然不起作用。我看不到这个工作函数(data){$('#resultdi').html(data);}@ickyrr是的,这个函数词应该是带有小写fThanks的函数来进行更正,我已经更新了控制台,现在控制台中没有错误,但是ajax cal仍然不工作