I have gotten JSONP working with an anonymous function but can't get it to work with a named function. This code works (the alert appears with the correct data):
$.getJSON('http://example.com/test.aspx?foo=bar&callback=?',
function (data) { alert(data.baz) })
However this code does not work (no alert appears):
function dat(data) {
alert(data.baz)
}
$.getJSON('http://example.com/test.aspx?foo=bar&callback=dat')
Can you explain why the last code does not work?
EDIT: I took out a non-relevant example