Home >Backend Development >PHP Tutorial >Examples to explain Ajax post request jump page

Examples to explain Ajax post request jump page

小云云
小云云Original
2018-05-24 10:50:213729browse

This article mainly introduces the relevant information of Ajax post request jump page. It is very good and has reference value. Friends in need can refer to it. I hope it can help everyone.

Recently, due to company needs, I need to request ajax post and jump to the interface. I searched for information online and found that window.location.href is almost used to handle it, but the request will be exposed in the address bar of the request page. parameters, which is unsafe.

$.post(
url,
{method:"regist",userName:$nameEle.val(),email:$emailEle.val(),password:$passwordEle.val()},
function(data) {
//注册成功页面跳转,
window.location.href ="../yiliaoqixie/login.html?name="+$nameEle.val();
}
);

Therefore, the only way to think of post submission is through the form form.

<form method="post" action="action" id="fm">
</form>
$.post(
url,
{method:"regist",userName:$nameEle.val(),email:$emailEle.val(),password:$passwordEle.val()},
function(data) {
//注册成功页面跳转,
  var fm=document.getElementById("fm");
  fm.submit();
}
);

Related recommendations:

A brief analysis of the usage differences between Jquery AJAX POST and GET

Jquery AJAX POST and GET difference

#Usage of ajax post in jquery

The above is the detailed content of Examples to explain Ajax post request jump page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn