Open URL while passing POST data with jQuery

Asked
Active3 hr before
Viewed126 times

4 Answers

jquery
90%

Request the test,php page and send some additional data along (while still ignoring the return results)

Example_snippet/controller/utility/_jquery.js/ $.ajax({ type: "POST", url: . . .
$.ajax({
   type: "POST",
   url: url,
   data: data,
   success: success,
   dataType: dataType
});
load more v
88%

If you mean that you want to change the current page URL, well then you can add a new <form> to the current page, add hidden input elements to it, and then submit it,,This seems like an unlikely situation, maybe you could comment with more details about the data being passed and its relation to the content of Page2?,If you are POSTing data not in a form (because you could simply set the form's action to the current page) and the data being posted isn't directly related to the content of the next page, you can use the callback function of jQuery's

Example_snippet/controller/utility/_jquery.js/ $('body').append($('<form/>') . . .
$('body').append($('<form/>')
  .attr({'action': yourNewURL, 'method': 'post', 'id': 'replacer'})
  .append($('<input/>')
    .attr({'type': 'hidden', 'name': 'param1', 'value': "hello"})
  )
  .append($('<input/>')
    .attr({'type': 'hidden', 'name': 'param2', 'value': "world"})
  )
).find('#replacer').submit();
load more v
72%

data: json data to be sent to the server with request as a form data, ,url: request url from which you want to submit & retrieve the data

Example_snippet/controller/utility/_jquery.js/ $.post(url,[data],[callback],[. . .
$.post(url, [data], [callback], [type]);
load more v
65%

Search Answer Titles

Example_snippet/controller/utility/_model.js/ $.post(url, function (data) { . . .
$.post(url, function(data) {
   var w = window.open('about:blank');
   w.document.open();
   w.document.write(data);
   w.document.close();
});