looking for ajax code that will allow me to load two xml files in two tables on the s

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kgee747
    New Member
    • Dec 2018
    • 1

    looking for ajax code that will allow me to load two xml files in two tables on the s

    Hi

    I am looking for ajax code that will allow me to load two xml files in two tables on the same webpage. I look at w3 schools and I have used the code template at https://www.w3schools.c om/js/js_ajax_xmlfile .asp get cd that loads XML files into a table AJAX XML Example
    The following example will demonstrate how a web page can fetch information from an XML file with AJAX but cant figure out how to use it to do do 2 tables one webpage using document.getEle mentById("demo" ).innerHTML = table;
    } not write
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    well - a solution would fully depend on how you would fetch the data - either with 1 or with 2 requests.

    if you would use 2 seperate requests then you could simply transfer the example you have to your problem - just make 2 requests and process the results in the callback function (in that example myFunction) - and make sure that your result elements have different ids that you would use for inserting the processed data.

    if you want to do only 1 request - then the response would have to be parsed differently depending on how the response would look like (since in that case you would have to have both documents in the response somehow - may be combined into 1 'envelope'-document or combined into json-response as values for keys like doc1 and doc2 or however the response would be built in that case) - but again - parse it as needed and append the results to 2 different parts of the page by using different ids for the 'base-elements' of the content you wish to show.

    you could use different attributes like class or even custom attributes of the elements instead of the ids - but ids are the 'easiest' to work with, since getElementById directly returns you a reference to a node with that id (given the node exists).

    Comment

    Working...