Thursday, February 20, 2014

Working on jQuery

jQuery:

jQuery is a cross platform java library which is used for client side  scripting of HTML.  jQuery is a free, open source software and it is most popular javascript library. jQuery is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website.

Working on jQuery:

For starting of jQuery we have to use its library in starting.

<script src="http://code.jquery.com/jquery-1.11.min.js"></script>
or we can use this js also in our own file.

example of jQuery:

$("div.test").add("p.quote").addClass("blue").slideDown("slow");

Here $ function is a factory method for jQuery object. This is also called command. Via $.-prefixed functions. These are utility functions, which do not act upon the jQuery object directly.

It is possible to perform browser-independent Ajax queries using $.ajax

$.ajax({
  type: "POST",
  url: "example.php",
  data: "name=John&location=Boston"
}).done( function(msg) {
  alert( "Data Saved: " + msg );
}).fail( function( xmlHttpRequest, statusText, errorThrown ) {
  alert(
    "Your form submission failed.\n\n"
      + "XML Http Request: " + JSON.stringify( xmlHttpRequest )
      + ",\nStatus Text: " + statusText
      + ",\nError Thrown: " + errorThrown );
});

No comments:

Post a Comment