The following code generates a syntax error or errors. The purpose of the line o
ID: 3838732 • Letter: T
Question
The following code generates a syntax error or errors. The purpose of the line of code is to make an AJAX get request which will send the variable choice to the PHP code to determine which data to send back. Once the data has been received from the PHP, the AJAX request will change the inner html of contentBox to whatever the PHP passes to it. Which rewrite of the line will correct the error or errors ?
$get(responder.php, [choice=1], function(data){
$(#contentBox).innerHTML(data);
});
$.get("responder.php", { "choice": 1 }, function(data){
$("#contentBox").innerHTML(data);
});
$.get(responder.php, { choice: 1 }, function(data){
$(#contentBox).html(data);
});
$.get("responder.php", [ "choice": 1 ], function(data){
$("#contentBox").innerHTML(data);
});
$.get("responder.php", { "choice": 1 }, function(data){
$("#contentBox").html(data);
});
$get("responder.php", { "choice": 1 }, function(data){
$("#contentBox").html(data);
});
$.get("responder.php", { "choice": 1 }, function(data){
$("#contentBox").innerHTML(data);
});
Explanation / Answer
You wont face any problem if you wrap you lines of code with document.ready event.
$(document).ready(function () {
$('#button').click(function () {
var string = $('#string').val();
$.get('responser.php', {input : string}, function (data) {
$('#feedback').text(data);
});
});
});
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.