I have to update one element on page with Ajax, do I have to make changes to server side, or is it possible to load whole page with jquery and then update only for example one element?
Share
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.
You don’t have to, and it is possible, but I would argue that you shouldn’t. One of the advantages of AJAX is that you are pulling a fragment off the server, and thus a smaller payload. If you’re pulling the entire page again, it will execute all the database queries, many of which will be unrelated to your element.
You will also request all CSS/JS again, all text, etc.
I would make a separate page for the individual fragment and request that via AJAX and update the element with just the returned result.
However you can do it, and jQuery provides this through its load method:
http://api.jquery.com/load/