我希望使用Ajax/jquery能够重定向到另一个php脚本来执行脚本中的命令。
我下面有一个jquery/ajax代码函数,我的问题是,为了重定向到"cancelimage.php“脚本,jquery.ajax函数是否正确?
$(imageuploadform).find(".imageCancel").on("click", function(event) {
$('.upload_target_image').get(0).contentwindow
$("iframe[name='upload_target_image']").attr("src", "javascript:'<html></html>'");
jQuery.ajax("cancelimage.php");
return stopImageUpload(2);
}); 发布于 2012-10-23 08:05:32
我不确定这是不是你想要的,但是为了完全重定向
Window.location.href='cancelimage.php'但是,如果您希望从代码中获得ajax成功/失败类型的响应
$.ajax{(
url:'cancelimage.php',
data: 'yourData', //either serialized from form submit or created on the fly
Success: function(yourResponse){ //if Conditions met
},
Error: function(request){ alert(request.responseText);}
)};然后,只需更新cancelimage.php脚本以返回布尔值true/false、使用json_encode的JSON对象或您喜欢的任何内容
https://stackoverflow.com/questions/13019763
复制相似问题