169
rated 0 times
[
170]
[
1]
/ answers: 1 / hits: 15621
/ 13 Years ago, mon, december 19, 2011, 12:00:00
I have this js file serving from some domain say foobar.com
at http://foobar.com/static/js/main.js:
$(document).ready(function() {
function foobar(bar){
$.ajax({
url: /site/foo/,
data: {'foo':bar},
dataType: jsonp,
crossdomain: !0,
success: function (data) {
alert(data);
},
error: function () {
}
})
}
});
On barfoo.com
on some url, I have something like this:
<script src='http://foobar.com/static/js/main.js' type='text/javascript'></script>
<script type='text/javascript'>foobar('123456')</script>
When I hit that url : it says
Uncaught ReferenceError:foobar is not defined (anonymous function)
How to access function from other domains?
More From » jquery