Php ajax没有得到执行
您好,我的项目中有ajax,在其他文件中也有,但对于这个特定的实例,我调用scripts/claim.php并通过GET传入id参数,它似乎不起作用 HTML JavascriptPhp ajax没有得到执行,php,javascript,html,ajax,Php,Javascript,Html,Ajax,您好,我的项目中有ajax,在其他文件中也有,但对于这个特定的实例,我调用scripts/claim.php并通过GET传入id参数,它似乎不起作用 HTML Javascript <script> function processclaim() { alert("hi"); var id=document.getElementById('claimid').value; alert(id); $.ajax({ type: "PO
<script>
function processclaim() {
alert("hi");
var id=document.getElementById('claimid').value;
alert(id);
$.ajax({
type: "POST",
url: "scripts/claim.php",
data: {id: id},
dataType: "json",
success: function(data) {
window.location = "profile.php";
}
});
alert(id);
}
</script>
函数processclaim(){
警报(“hi”);
var id=document.getElementById('claimid')。值;
警报(id);
$.ajax({
类型:“POST”,
url:“scripts/claim.php”,
数据:{id:id},
数据类型:“json”,
成功:功能(数据){
window.location=“profile.php”;
}
});
警报(id);
}
警报工作,显示“hi”和传递的正确id。如果您可能从服务器返回错误,请将该状态添加到Ajax调用中
$.ajax({
type: "POST",
url: "scripts/claim.php",
data: {id: id},
dataType: "json",
success: function(data) {
window.location = "profile.php";
},
error: function() {
console.error("ERROR!", arguments);
}
});
我猜您正在将返回的数据类型设置为JSON,而不是从服务器返回JSON 您是否使用浏览器开发人员工具来查找AJAX调用得到的响应?
&&isset($\u POST['id']){
通过GET。?什么是$\u POST['id']
值?如果执行了状态,您的值是多少?不,我该怎么做
<script>
function processclaim() {
alert("hi");
var id=document.getElementById('claimid').value;
alert(id);
$.ajax({
type: "POST",
url: "scripts/claim.php",
data: {id: id},
dataType: "json",
success: function(data) {
window.location = "profile.php";
}
});
alert(id);
}
</script>
$.ajax({
type: "POST",
url: "scripts/claim.php",
data: {id: id},
dataType: "json",
success: function(data) {
window.location = "profile.php";
},
error: function() {
console.error("ERROR!", arguments);
}
});