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 *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...