What kind of requests we can make using $.ajax?
We can make any request like get, post, put and delete. $.ajax function accepts parameters called type which will decide what request we want do.
What is the difference between $.ajax and $.post?
- $.post is simpler representation of $.ajax for POST requests. When we are using $.posits not required to specify the type. It will be always ‘post’.
- If you are willing to make a post request and we expecting have more control over HTTP headers. $.ajax is the best choice. If your only invention is to make a post hit to server $.post is best.
ContentType represents the data type of data we are going to send from Javascrip whereas datatype represent the data type of data we are expecting from Serverside in return.
What is $.getJSON in jQuery?
It is just shorthand representation of $.ajax where type is set to “GET” and datatype is set to “JSON” automatically.
For technical trainings on various topics like WCF, MVC, Business Intelligence, Design Patterns, WPF, TFS and Basic fundamentals feel free to contact SukeshMarla@Gmail.com or visit www.sukesh-marla.com
For more stuff like this, click here. Subscribe to article updates or follow at twitter @SukeshMarla
See .NET AJAX jQuery interview questions video on explaining jQuery with example: -