Reputation: 15408
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?
Upvotes: 4
Views: 6161
Reputation: 4295
Use the dataType: 'script'
option
$.ajax({
url: $(this).attr("href"),
type: 'DELETE',
dataType: 'script'
});
Or simply,
$.getScript($(this).attr("href")); // Won't use 'DELETE' http type
Upvotes: 5