Reputation: 29
For this line of code :
var result = eval('('+result+')');
In this context:
function saveUser(){
alert(url);
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.errorMsg){
$.messager.show({
title: 'Error',
msg: result.errorMsg
});
} else {
$('#dlg').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the user data
}
}
});
}
How do i fix the error?
Upvotes: 0
Views: 3680
Reputation: 816312
what does Uncaught SyntaxError ... mean?
It means that eval
cannot parse the input (as JavaScript) because it contains a <
where there shouldn't be one. FWIW if the response is HTML, JSON.parse
wouldn't help either.
How do i fix the error?
You either have to treat the response how it is expected to be treated, e.g. don't pass it through eval
if it's HTML.
Or you fix the server side and return the repsonse that the client side expects, e.g. JSON.
Upvotes: 2