Jquery Interview questions and Answers For Developers Part-7
62. Can we use jQuery to make ajax request?
Yes. jQuery can be used for making ajax request.
63. What are various methods to make ajax request in jQuery?
Using below jQuery methods, you can make ajax calls.
load() : Load a piece of html into a container DOM
$.getJSON(): Load JSON with GET method.
$.get(): Use to make a GET call and play extensively with the response.
$.post(): Use to make a POST call and don’t want to load the response to some container DOM.
$.ajax(): Use this to do something on XHR failures, or to specify ajax options (e.g. cache: true) on the fly.
64. Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()?
By using jQuery post()/ jQuery get(), you always trust the response from the server and you believe it is going to be successful all the time. Well, it is certainly not a good idea to trust the response. As there can be n number of reason which may lead to failure of response.
Where jQuery.ajax() is jQuery’s low-level AJAX implementation. $.get and $.post are higher-level abstractions that are often easier to understand and use, but don’t offer as much functionality (such as error callbacks).
65. What are deferred and promise object in jQuery?
Deferred and promise are part of jQuery since version 1.5 and they help in handling asynchronous functions like Ajax.
66. Can we execute/run multiple Ajax request simultaneously in jQuery? If yes, then how?
Yes, it is possible to execute multiple Ajax request simultaneously or in parallel. Instead of waiting for first ajax request to complete and then issue the second request is time consuming. The better approach to speed up things would be to execute multiple ajax request simultaneously.
Using jQuery .when() method which provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
67. Can you call C# code-behind method using jQuery? If yes,then how?
Ans: Yes. We can call C# code-behind function via $.ajax. But for do that it is compulsory to mark the method as WebMethod.
68. Which is the latest version of jQuery library?
Ans: The latest version (when this post is written) of jQuery is 1.10.2 or 2.0.3. jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8.
69. Does jQuery 2.0 supports IE?
Ans: No. jQuery 2.0 has no support for IE 6, IE 7 and IE 8.
70. What are source maps in jQuery?
Ans: In case of jQuery, Source Map is nothing but mapping of minified version of jQuery against the un-minified version. Source map allows to debug minified version of jQuery library.