Reputation: 6339
I am new to both javascript and jQuery. I am developing a page in which I have generated page's whole html from code. In the page, there in a textbox to post messages and for each message comments can be posted. Now when I post a new comment or delete a comment I need to do database call. I know 2 method to do it from js
- do xmlhttprequest
- do ajax call from jQuery.
Can anybody suggest me which method will suite my requirement?
Upvotes: 6
Views: 13092
Reputation: 404
At least today jQuery isn't a clean or even a fast solution, from this test the results for me in mobile or desktop shows that jQuery are, at least, 80% slower than XHR2: https://jsperf.com/xhr-vs-jquery-ajax-vs-get-vs-fetch
Upvotes: 1
Reputation: 123831
xmlhttprequest is not working through cross-browser, for example some IE versions, so best option is jQuery's ajax call.
Upvotes: 3
Reputation: 187040
jQuery itself will be using XMLHTTPRequest object. What it provides will be a wrapper for the functions. So if you want to avoid the burden of writing javascript that targets various browsers then you can opt for jQuery.
Upvotes: 2
Reputation: 28429
Each browser has their own implementation of XmlHttpRequest. Using a framework will minimize the headache of cross-browser differences and quirks, especially if you are very new.
Upvotes: 11