Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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);

});

});

});

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote