I’m not too great with jquery and maybe this title doesn’t explain too well what i want to do but here goes:
$.ajax({
url: 'my_action',
dataType: 'script',
beforeSend: function() { //can i not just call a script here instead?
if (1 == 1) //just an example
{
return false
}
},
complete: function() {
console.log('DONE');
}
});
So in beforeSend, I want to call a script rather than have an inline function. This is because my function is quite long and it makes the ajax code I have looks messy.
Is that possible?
Rewrite your request as follows to load the external JavaScript file before Ajax call.