如何根据回复调用更改ajax url
$.ajax({
url: "/url/1/1",
dataType: "json",
success: function (response) {
if (response) {
// i want to change url based on response
//example var next = response.next
// den i want to call url as /url/1/next.
}
}
});
答案 0 :(得分:0)
$.ajax({
url: "/url/1/1",
dataType : "json"
}).done(function(response) {
if ('next' in response) {
document.location.href = '/url/1/' + response.next;
}
});
答案 1 :(得分:0)
$.ajax(
{
url: "/url/1/1",
dataType : "json",
success: function(response)
{
if(response)
{
// i want to change url based on response
//example var next = response.next
// den i want to call url as /url/1/next.
-----------------after response----------
var next = response.next
$.ajax(
{
url: "/url/1/"+next,// you can set like this
dataType : "json",
success: function(response)
{.....
}
});
-------------------------------------
}
}
});