我正在尝试从Ajax函数中打开一个URL,但不会调用该URL。
这是我的代码:
$(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);
}
});
});
});
那里有什么问题?
答案 0 :(得分:2)
你不能像这样调用对象属性键。这不是变数。
这样做:
var url = "ondemand_driver.php";
$.ajax({
url : url,
type: "POST",
data : value,
success: function() {
window.location = url;
}
});
答案 1 :(得分:1)
将url声明为ajax函数的变量
SELECT CASE ReceivePayment.PaymentType
WHEN 'Sale' THEN SELECT Name FROM Vendor WHERE VendorID = ReceivePayment.AccountID
WHEN 'Purchase' THEN SELECT Name FROM Customers WHERE CustID = ReceivePayment.AccountID
END
FROM ReceivePayment
工作正常。
答案 2 :(得分:0)
您需要将 url 定义为变量,只有在ajax请求成功时才会打开该网址。