By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,902 Members | 1,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,902 IT Pros & Developers. It's quick & easy.

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

P: 1
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.com/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.getElementById("demo").innerHTML = table;
} not write
Dec 24 '18 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,295
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).
Dec 27 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.