html - Using Ajax with Javascript -


my assignment make 2 separate paragraphs hide , show using jquery. have done successfully. our next step add in javascript ajax code in order allow 2 paragraphs show , hide. have created 2 separate html files in order accomplish this.

my problem is, can't figure out how display both paragraphs @ once. either 1 shows or 1 paragraph appears twice, in both divs.

thank you!

var xhr = new xmlhttprequest(); xhr.onload = function(){     if (xhr.status === 200){         document.getelementbyid('get').innerhtml = xhr.responsetext;         document.getelementbyid('set').innerhtml = xhr.responsetext;     } }; xhr.open('get', 'share.html', true); xhr.send(null); xhr.open('get', 'network.html', true); xhr.send(null); 

that's because in onload callback of xhr request, you're setting both get , set elements same response text, why 1 paragraph appears twice.

create 2 different xmlhttprequest objects , have different onload handlers.

or if you're using jquery, why not jquery load method?

$("#get").load("share.html");  $("#set").load("network.html"); 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -