When I return the value of a AJAX form that submits an API I get this:
SyntaxError: Unexpected token &
The AJAX response handling looks like this:
$(document).ready ->
$(".edit_code_lesson").on("ajax:success", (e, data, status, xhr) ->
result = JSON.parse(data)
alert(result);
).bind "ajax:error", (e, xhr, status, error) ->
console.log(status + '\n ' + error);
console.log(xhr);
After looking at the responseText from the xhr I can see the response is:
"{"stdout"=>"2\n", "stderr"=>"", "wallTime"=>237, "exitCode"=>0}"
I am new to HTML so I am unsure if the response should be in HTML. How can I fix this?
NOTE: This is a Rails App using an API wrapper.