Results 1 to 4 of 4
  1. #1

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

    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.

  2. #2
    Join Date
    Aug 2005
    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 <div>. 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.

  3. #3
    Join Date
    May 2009
    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.

  4. #4
    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.

Similar Threads

  1. Ajax var code
    By horizon in forum Programming Discussion
    Replies: 1
    Last Post: 02-18-2009, 03:35 PM
  2. Ajax lib - update an element with ANY html code
    By 01globalnet in forum Programming Discussion
    Replies: 6
    Last Post: 10-10-2008, 02:17 PM
  3. simple php code needing converted to asp code.
    By lochie in forum Programming Discussion
    Replies: 2
    Last Post: 08-30-2007, 04:33 AM
  4. How can i optimize the JS Ajax Code?
    By latheesan in forum Programming Discussion
    Replies: 4
    Last Post: 12-18-2006, 09:10 PM
  5. PHP Code Question...really quick and simple..
    By darthvadersmaster in forum Programming Discussion
    Replies: 4
    Last Post: 03-13-2006, 01:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts