Ajax函数成功后打开URL [英] Open URL after success in Ajax function
本文介绍了Ajax函数成功后打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过Ajax函数打开URL,但未调用该URL.
I am trying to open an URL from an Ajax function, but the URL is not called.
这是我的代码:
$(document).on( "click",".btndriver", function() {
var id = $(this).attr("id");
var nombre = $(this).attr("nombre");
swal({
title: "Select Driver?",
text: "Select Driver? : "+nombre+" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "GO",
closeOnConfirm: true },
function(){
var value = {
id: id
};
$.ajax(
{
url : "ondemand_driver.php",
type: "POST",
data : value,
success: function() {
window.location(url);
}
});
});
});
那是怎么了?
推荐答案
您不能只这样调用对象属性键.这不是变量.
You can't just call an object property key like that. It's not a variable.
只需执行以下操作:
var url = "ondemand_driver.php";
$.ajax({
url : url,
type: "POST",
data : value,
success: function() {
window.location = url;
}
});
这篇关于Ajax函数成功后打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文