Saturday, December 26, 2009

Re: [jQuery] Simple jQuery Ajax - Using PHP Variables

lots of examples in the AJAX section of jQuery.com.http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype
 For your case following should work:
var valueIwantToSend="1223";
$.get("scriptname.php", { variable: valueIwantToSend},function(data){
    $("#results").html(data)
 });


egressor wrote:
I have consulted numerous books, and have searched online in vain to find an answer to this simple question.  Here is a case:  I have a simple PHP script that I can run either in the browser or in the shell by typing something something similar to this: scriptname.php?variable=value  Now let's assume that the variable is a simple string, and not something complicated as an array. Let's also assume that the output of the PHP script, is plain xHTML and the jQuery Ajax will insert it into a div or span id="results".  Can someone provide an idiots guide to this, and also some code?  Thank you, Chris    

No comments: