gpt4 book ai didi

javascript - 在 Ajax 调用中更改 URL 的问题

转载 作者:行者123 更新时间:2023-11-30 09:55:20 26 4
gpt4 key购买 nike

我有一个关于分页概念的休息服务电话。现在,在单击下一个按钮/图标的分页概念中,我可以调用其余服务,它返回所需的值,但 URL 没有改变,我需要更改 URL 中的页码。我的代码是下一个图标事件如下,'

function nextPage(currentPage, totalPageCount) {
alert(currentPage+ " Begin nextPage Method " + totalPageCount);
var nextPage = currentPage+1;
var ctx = "${context}";
var url = ctx+"/adtrack/storelist/National/1/"+nextPage;
console.log(url);
if(nextPage <= totalPageCount)
{
jQuery.ajax({
url: url,
type: "GET",
success: function(msg) {
alert("Success");
},
error : function(msg) {
alert("Fail");
}
});
}
else{
alert("Unable to perform the action!!!");
}
// return true or false, depending on whether you want to allow the `href` property to follow through or not
}

在上面的调用中,它会点击 URL 并返回值,但我还需要将当前 URL 更改为最新 URL。如何更新 URL?

无论我点击的 URL 是什么,该 URL 都必须更新为浏览器的当前 URL

最佳答案

您好,我的建议是尝试将 nextPage 变量声明为全局变量,因为每当您点击该函数时,新值将分配给该 nextPage 变量。所以也请尝试

     var nextPage=0;

function nextPage(currentPage, totalPageCount) {
/......../

nextPage= currentPage+1;

/......../

关于javascript - 在 Ajax 调用中更改 URL 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34333831/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com