jqueryajax

Is my code Jquery or AJAX?


I heard that AJAX use xml concept. But I had some doubt that whether the following code is JQUERY or AJAX. Find it for me. Give me differences between Jquery and AJAX

$(".changepass").click(function() {
   $(".loading").show();
   $(".block1").load("views/changepass.template.php", function(){ $(".loading").hide(); });
   return false;
 }

Solution

  • The code is in jQuery and is used to load HTML from a remote file and inject it into the DOM. In this case you are injecting the HTML to an element with class 'block1'.

    $(".changepass").click
    

    attaches a clink event to element with class 'changepass'

    See click

    $(".loading").show();
    

    show an element with class 'loading'

    See show

    $(".block1").load
    

    loads an HTML to element with class 'block1' using AJAX.

    See load