Reputation: 390
I am pulling my hair out with this. I am trying to invoke a getJSON and the callback function is never triggered. I tried adding an alert as well as firebug debug but the callback never happens.
The service response shows a JSON string so not sure what is going wrong. Any pointers?
Here is my code which calls a Play Framework service:
var serviceURL = "http://localhost:9000/signup/";
var employees;
$('#employeeListPage').bind('pageinit', function(event) {
$.mobile.allowCrossDomainPages = true;
getEmployeeList();
});
function getEmployeeList() {
$.getJSON(serviceURL + 'getemployees?callback=?', function(data) {
alert(data);
$('#employeeList li').remove();
employees = data.items;
$.each(employees, function(index, employee) {
$('#employeeList').append('<li><a href="employeedetails.html?id=' + employee.id + '">' +
'<img src="pics/' + employee.picture + '"/>' +
'<h4>' + employee.firstName + ' ' + employee.lastName + '</h4>' +
'<p>' + employee.title + '</p>' +
'<span class="ui-li-count">' + employee.reportCount + '</span></a></li>');
});
$('#employeeList').listview('refresh');
});
}
The play service returns a json string.
Anyone see what am i doing wrong? why is the alert never executed?
Upvotes: 2
Views: 1831
Reputation: 21174
Some debugging tips:
console.log('getEmployeeList()')
command right at the top of that function. If it's not being called, then my guess would be that #employeeListPage
does not exist (at least, not when you are expecting it to.)EDIT Based on comments - seems that the Play framework does not natively support JSONP. I'm not sure whether you have any control over that. http://groups.google.com/group/play-framework/browse_thread/thread/253107904a5c98f8
Upvotes: 1