Ajax calls don't reload the page.

The easiest way is to use JSON:

$('li').click(function(){

   var _name = $(this).text();
   $.getJSON("getdata.php",{ name: _name }, function(data)
{ alert('name is: '+ data.name) });

});

Then your server script must return a Javascript object:

{ name: 'Dolly' }

Alternatively you can use the base ajax function:

   $.ajax({
     type: "GET",
     url: "getdata.php",
     data: {name: _name},
     dataType: "json",
     success: function(){

     }
   });

http://docs.jquery.com/Ajax
http://en.wikipedia.org/wiki/JSON

Make sure you're protecting your site from SQL injection attacks by
filtering/escaping the input server-side also. (http://
en.wikipedia.org/wiki/SQL_injection)

- ricardo

On Oct 19, 11:01 pm, OscarGodson <[EMAIL PROTECTED]> wrote:
> I have searched the web over and over and I can't figure out how to do this.
> I know jQuery very, very well, but I just haven't used AJAX before.
>
> All I want to do is simply
> When someone clicks a <li>
> I want to get its text()
> Use that text as var name = $(this).text();
> Use name as the row (var name will be equal to the name in the DB) I want to
> call from the SQL db.
>
> I want the DB to send the info to a php page and then I want it to update
> TinyMCE(WYSIWYG).
>
> My main problem is I cant figure out how to get data from a SQL db and have
> it update on the page without it reloading.
> --
> View this message in 
> context:http://www.nabble.com/Simple-AJAX-Question-tp20061821s27240p20061821....
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to