我可以在 Ajax 成功后执行 "post" 操作吗
Can I do a "post" action on success of Ajax
我有以下代码:
$.ajax({
type: "post",
url: "./api/v1/bluemix/auth",
data: datas,
success: function(data){
var successUrl = "CreateBluemixMonkey.jsp";
window.location.href = successUrl + "?data=" + newdata ;
},
error: function(jqXHR,error, errorThrown) {
alert("Error");
}
})
成功 AJAX 调用后,我正在设置 window.location.href
。相反,我可以对同一个 JSP 做另一个 post 吗?我正在尝试使用隐藏值,但我怀疑,因为没有 post 方法。我将所有隐藏字段值作为 null
in CreateBluemixMonkey.jsp.
您可以在包含一些隐藏输入的页面上创建一个,然后调用提交方法。这样你生成一个 POST-Request 而不是 GET-Request,它是从 window.location.href 代码行生成的。
如果可能,只需在您的页面上创建一个隐藏的静态,最好将 'display: none;'
设置为 CSS-Style。然后在您的成功函数中给表单标签一个 ID 和 运行 $('#form-id').submit();
。
我有以下代码:
$.ajax({
type: "post",
url: "./api/v1/bluemix/auth",
data: datas,
success: function(data){
var successUrl = "CreateBluemixMonkey.jsp";
window.location.href = successUrl + "?data=" + newdata ;
},
error: function(jqXHR,error, errorThrown) {
alert("Error");
}
})
成功 AJAX 调用后,我正在设置 window.location.href
。相反,我可以对同一个 JSP 做另一个 post 吗?我正在尝试使用隐藏值,但我怀疑,因为没有 post 方法。我将所有隐藏字段值作为 null
in CreateBluemixMonkey.jsp.
您可以在包含一些隐藏输入的页面上创建一个,然后调用提交方法。这样你生成一个 POST-Request 而不是 GET-Request,它是从 window.location.href 代码行生成的。
如果可能,只需在您的页面上创建一个隐藏的静态,最好将 'display: none;'
设置为 CSS-Style。然后在您的成功函数中给表单标签一个 ID 和 运行 $('#form-id').submit();
。