I have the following ajax call
var response = "";
//Ajax call to the DB server
var target_url = "http://SomeIP/db/*create_table*?token=1234qwer&table_name="+table_name+"&array_of_fields={"+final_fields+"}";
function hit_db(callback)
{
$.ajax({
url: target_url,
type: 'GET',
async: true,
crossDomain: true,
success: callback,
});
}
hit_db(function(data){
response = data;
alert(response);
});
However alert(reponse)
shows undefined
when the correct output should be ERROR table already exists
However, when I check on my dev. tools I see the following
and If I click on the link of the Uncaught SyntaxError it takes me to this page where the correct output is displayed
Why is the correct output I want in that Unexpected Identifier but I get undefined alert(response)
? Any possible fixes?
EDIT------
Here's some simplified code and the response
function hit_db(callback)
{
$.ajax({
url: target_url,
type: 'GET',
success: callback,
});
}
hit_db(function(data){
response = data;
console.log(response);
});
Thank you!!