I need to retrieve a simple page and use the data that it returns. Is there any difference between $.post() and $.get() should I be using one over the other?
I don’t plan on submitting any data with the request.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you just want to retrieve the contents from an html document, use
$.load()instead.You can even retrieve partial information from that document by providing an additional selector:
see http://api.jquery.com/load/
To answer your question more generally, its no big difference whether you’re using a
POSTor aGETrequest to a server, it depends on the amount of data you need to send. Typically, aGETrequest is limited to 2083 (because IE limits the query-string). So if you have a lot of data to send, you should use aPOSTrequest.Technically, a
GETrequest should be slightly faster. Because internally only one packet is sent instead of at least two (one for the header and one for the transmission body). But that really is high performance optimizing.