ajax post to jsp receive null string -


I am using jquery to fetch data from a form and posting it to a .jsp file with ajax. When I try to get the data in jsp scriplet using the request.get parameter, I get zero.

  var value = {}; // Generate an empty javascript object $ ("select"). Select the value at each (function () {// iterative [$ (this) .attr ('name')] = $ (this) .find (": selected") .attr ('data-citcode'); Value "[addpicker1] = $ (" # datepicker1 div "). Date picture (" getFormattedDate ", format); value [" Datepicker2 "] = $ (" # datepicker2 div "). Recorder (" getFormattedDate ", format); // var url =" list_flights.jsp "; $ .ajax ({type:" GET ", url:" list_flights.jsp ", Async: false, data: {values: JSON.stringify (values)}, error: function (data) {console.log (data);}, success: function (data) {console.log (data); window .location = "List_flights.jsp";}});  

and jsp written

  & lt;% out.print (request.getParameter ("value" );; & Gt%;  

Output
null

It seems that you are changing the window space on AJAX

  success: function (Data) {console.log (info); Window.location = "list_flights.jsp"; }  

is making another request and you do not have a value property in the request.

  Success: Function (data) {Console.log (data); Window.location = "list_flights.jsp? Values ​​=" + JSON. String (value); }  

But this does not mean to redirect the code to success and AJAX to the same JSP. You should call servlet from AJAX which will give you feedback and depending on that feedback you should redirect to another page.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -