jQuery: How to enable beforeSend for $.ajax({dataType:'jsonp'...? Is there any solution?
http://jsfiddle.net/laukstein/2wcpU/
<div id="content"></div>
<script>
$.ajax({
type:"GET",
url:'http://lab.laukstein.com/ajax-seo/.json',
dataType:'jsonp',
async:false,
beforeSend:function(data){ // Are not working with dataType:'jsonp'
$('#content').html('Loading...');
},
success:function(data){
$('#content').html(data.content);
}
});
</script>
This is just the nature of how JSONP works, creating a
<script>tag, not actually using aXMLHttpRequestto get data.For what you’re doing, you can just run the code before, like this: