I am relatively new to Jquery and I was wondering how would one post variables to another page and then redirect? I used ajax function, the redirect works fine, but no varia
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "LinkTagOut.aspx",
dataType: "json",
data: { id: 1 }, // or the string: 'id=1'
complete:
function () {
window.location = "LinkTagOut.aspx";
}
});
From the $.ajax documentation (data
option):
Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).
Also, make sure to return false
from the end of the submit handler (or whatever fires the ajax call) to ensure that a 'normal' redirect is not happening.