Menu Search Me

JQuery AJAX Functions

Below is an example of using JQuery's AJAX $post() method.

This function will post back profile data using ajax, and display result when response comes back asynchronously. The result is a JSON string:

function profileChange() {
   var result = "";
   var message = "";
   email = document.getElementById("email").value;
   firstname = document.getElementById("firstname").value;
   lastname = document.getElementById("lastname").value;
   var url = "/";
         result = JSON.parse($.trim(data)).result;
         if (result=="error") {
            message = "There is an error!";
            $("#txtMessage").css("color", "red");
        else {
           message = "Your change is successfully saved!";
           $("#txtMessage").css("color", "black");