Portal Home > Knowledgebase > Articles Database > Very simple AJAX question (I don't need code)


Very simple AJAX question (I don't need code)




Posted by lexington, 08-31-2009, 03:11 AM
Hello, as you know usually AJAX uses a DIV and a function to display content on a section of your web page. If I have more than one part of the page that I want updated at the click of a button, do I simply create different functions and add them to the onclick or whatever javascript call I am using? If so, will that cause a lot of lag? Basically I would like for one button to do more than one thing, like update stuff in the header that is sitewide, and also update stuff going on specifically on that web page alone. Thanks.

Posted by Xeentech, 08-31-2009, 04:47 AM
Tricky to know where to start here. I think you need to change your idea of what "AJAX" is. It's not a method to update the content of a
. It can be used for that, but so so much more. It's a method of transferring data from one side to the other. If you think of it like that.. of course it's possible to update the content of two areas in the DOM. You just need to send that data down to the client is such a way that the code receiving it cat separate it and know where to insert what.

Posted by mattle, 08-31-2009, 07:04 AM
It is a tricky situation. The typical AJAX sample code usually creates an XML request object and then sets a handler that responds to status changes. The function will finish execution before the XML object receives data back from the server, so you need to keep your request variable at a higher scope than the calling function. If you simply call the function twice, you will replace the contents of the variable with a second XML object before processing the return status of the first function call, therefore you will need a second variable at a global scope to process two requests at the same time, and you'll need to pass the XML object variable as a parameter to the function that sends the request and attaches the event handler to it.

Posted by siv9, 09-02-2009, 11:40 AM
Lookup jQuery on google. Don't try to patch together some javascript and hope it works. jQuery makes Ajax, and really anything javascript related, MUCH easier! Plus, with all the different browsers, JavaScript tends to not be to cross browser compatible without using a framework such as jQuery, unless you have tons of if/else's to match all the different browser functions.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Sharktech Cloud (Views: 509)
Onmouseover in IE (Views: 462)
Server Overload (Views: 471)