Trying to add data to sql from link click and return results via jquery or ajax
I am not familiar with jquery or ajax, but i do know it is whats needed to perform the开发者_开发百科 action I want. I have created a wordpress plugin that updates a database table based on the users click. Right now it refreshes the page to return the results, but I want to stop the page refresh and return data via ajax I believe. If anyone is interested in helping me figure this out I would be very appreciative or even willing to pay.
Thanks
You said you've written some PHP. This does the actual databse update I hope?
Add to this script so it also echoes whatever data you need to update the page. (If its more involved than plain text you might need to look into JSON or something else)
jQuery has convenient functions for ajax. You said you're using jQuery already right? http://api.jquery.com/category/ajax/
$.load
is the simplest if all you need to do is update a single element of the page to the ajax response. If you need to do more check out $.get
$.post
or $.ajax
$('#ajaxresponse').load('urlofscript.php');
精彩评论