Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to redirect in jQuery using POST instead of GET
    primarykey
    data
    text
    <p>In my jQuery function I'm redirecting Using window.location.href like this:</p> <pre><code>window.location.href = "${pageContext.request.contextPath}/redirectUser.ajax?login="+response.result.name; </code></pre> <p>It works fine, but I see this String in browser like this:</p> <pre><code>http://localhost:8080/task7/redirectUser.ajax?login=user </code></pre> <p>My controller also uses GET</p> <pre><code>@RequestMapping (value="/redirectUser.ajax",method = RequestMethod.GET) public String forwardUserToUsersPage(ModelMap model, HttpServletRequest req){ User foundedUser = userDao.findByLogin(req.getParameter("login")); req.getSession().setAttribute("user", foundedUser); return "userPage";//to WEB-INF/jsp/userPage.jsp } </code></pre> <p>How can I rewrite this part of application in order to user POST method to redirect and to handle in controller ? </p> <p>Here is function that receives reply from servler (part of function actually)</p> <pre><code>function doAjaxPost() { // get the form values var queryString = $('#loginform').formSerialize(); $.ajax({ type: "POST", url: "${pageContext. request. contextPath}/loginUser.ajax", data: queryString, //"name=" + name + "&amp;pswd=" + pswd, success: function(response){ // we have the response var delay = 1500; if (response.status == "OK_USER") { $('#error').html(''); $('#info').html("Login exists, password is correct everything will be fine.&lt;br&gt; Redirect to User's page"); //var delay = 3000; setTimeout(function() { window.location.href = "${pageContext.request.contextPath}/redirectUser.ajax?login="+response.result.name; }, delay); } .... </code></pre> <p>So how can I redirect using jQuery or something else using POST method ? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload