PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You create a Web page that contains the span shown in the following line of code.
<span id=”span1″>Text</span>
You need to replace the contents of the span with HTML that you download from a URL specified by
a global variable named localURL. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
$.ajax({
type: “GET”,
url: localURL,
dataType: “jsonp”,
success: function(htmlText) {
$(“#span1”).text(htmlText);
}
});

B.
$.ajax(localURL, {},
function(htmlText) {
$(“#span1”).html(htmlText);
},
“html”
);

C.
$.ajax({
type: “GET”,
url: localURL,
dataType: “html”,
success: function(htmlText) {
$(“#span1”).innerHTML = htmlText;
}
});

D.
$.ajax({
type: “GET”,
url: localURL,

success: function(htmlText) {
$(“#span1”).html(htmlText);
}
});

Explanation:
CHAPTER 9 Working with Client-Side Scripting, AJAX, and jQuery
Lesson 3: Implementing jQuery
Implementing AJAX with jQuery (page 536)

One Comment on “Which code segment should you use?


Leave a Reply