Skip to content

Commit a4f8f4d

Browse files
committed
jsonp action!
1 parent 98b5587 commit a4f8f4d

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

‎v3/js/matrixtutor.js‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,30 @@ $(document).ready(function() {
281281
$('#submitGradeBtn').html('Now Grading ...');
282282
$('#submitGradeBtn').attr('disabled', true);
283283

284-
$.get('submit_matrix_problem.py',
285-
{submitted_code: pyInputCodeMirror.getValue(),
286-
problem_name: problemName},
287-
function(dataFromBackend) {
288-
$('#gradeStdout').val(dataFromBackend.user_stdout);
289-
290-
$('#submitGradeBtn').html('Submit for Grading');
291-
$('#submitGradeBtn').attr('disabled', false);
292-
},
293-
"json");
284+
// some JSONP action!
285+
// http://learn.jquery.com/ajax/working-with-jsonp/
286+
$.ajax({
287+
url: "http://104.237.139.253:4000/grade",
288+
// The name of the callback parameter, as specified by the YQL service
289+
jsonp: "callback",
290+
// Tell jQuery we're expecting JSONP
291+
dataType: "jsonp",
292+
data: {submitted_code: pyInputCodeMirror.getValue(),
293+
problem_name: problemName},
294+
295+
// Work with the response
296+
success: function(dataFromBackend) {
297+
if (dataFromBackend.err) {
298+
$('#gradeStdout').val(dataFromBackend.err);
299+
} else {
300+
// don't reveal the error messages to the student
301+
$('#gradeStdout').val(dataFromBackend.user_stdout);
302+
}
303+
304+
$('#submitGradeBtn').html('Submit for Grading');
305+
$('#submitGradeBtn').attr('disabled', false);
306+
},
307+
});
294308
});
295309
}
296310
});

0 commit comments

Comments
 (0)