Before I forget – Sending POST variables using jQuery

Written by James McDonald

April 5, 2011

You can pass in POST variables as follows with key=value pairs thusly:

$.ajax({ 
   type: "POST", 
   url: "some.php", 
   data: "name=John&location=Boston", 
   success: function(msg){ 
     alert( "Data Saved: " + msg ); 
   } 
 });

or using an object

var ref_num_url = "http://yourserver/cgi-bin/refnum.pl"; 	
	
$.ajax ({
	url: ref_num_url,
	type: "POST",
	data: { "environment": 'TEST', "blah": "foo"},
	dataType: "xml",
	success: function(myxml){
                      // this says using the returned xml find the
                      // refnum element and give me the text in it
                      // e.g 1234567 returns 1234567
	         alert($( myxml, "refnum").text());
	} 

}); // end ajax

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...