I have a link, which I want to make a DELETE request with JQuery with AJAX.
if(confirm("Are you sure?")) {
$.ajax({
url: $(this).attr("href"),
type: 'DELETE',
success: function(result) {
// Do something with the result
}
});
}
result is a wad of Javascript I would like to run. How do I get it to run my returned script?
eval, just return some kind of identifier and let your Javascript decide what to do.evalshould be avoided whenever possible. I don't think there is a real reason for returning a piece of code. You could return some kind of JSON, and define in your Javascript what should happen to it.