68 774
Assignments Done
Successfully Done
In January 2019

Answer to Question #59525 in AJAX | JavaScript | HTML | PHP for shambhavi dhir

Question #59525
JS: /*Dynamically add two buttons on page load and these buttons should call getImage1Data and getImage2Data in the JS file. Please don't use any libraries.*/
6) Write Sample code for dynamically creating image tag for first image to the div.
7) Add background to right div with src from 2nd request to cover parent background.

JavaScript File :

function getImage1Data(){
var image1Src;
var xhttp = new XMLHttpRequest();
xhttp.open("Get", 'some Url', false);
image1Src = xmlhttp.responseText; //Assume src = 'myFirstImg.png', 200x200 px

function getImage2Data(){

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
xhttp.open("Get", 'some Url', true);

function getSrc(text){
image2Src = text; //Assume src = 'myLastImg.png', 10x10 px
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions