If I do an AJAX post with jQuery that looks like
$.post('MyApp/GetPostResult.json', function(data) {
// what goes here?
});
and the result looks like
{
"HasCallback": true,
"Callback": "function(){ alert('I came from the server'); }"
};
Then how do I call the Callback function? Can I just write if(data.HasCallback){data.Callback();} ?
This should work:
Edit: Didn’t look quite carefully enough. If you’re indeed getting the
function() { ... }text, then you need toeval(data.Callback + "()").