acidzombie24 acidzombie24 - 1 year ago 88
Ajax Question

Ajax Links and jquery

Going with the just jquery it joke i was wondering in my website i have a link that says "Add". After clicking it the page refreshes and it says remove. I figure this would be better with ajax and not require the page to reload. How do i do this with jquery (should i do it in jquery?) and how do i know when the server receives the add so i can update my picture (i am sure there is a processing/complete state?)

Answer Source

jQuery AJAX functions let you specify success and failure functions which you can use to update your page.

$("#mylink").click (function (event) {
    type: "POST", // or GET
    url: "/my/address.php",
    data: "someData=someThing&someMore=somethingElse",
    success: function(data) {
    error: function() {
      // something's gone wrong.

  event.preventDefault(); // stop the browser following the link

For more read the jQuery AJAX page - it has loads of examples).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download