I’ve looked around for a while now, seen many similar problems, but none that help. I have a getJSON call that calls my Spring controller and responds with JSON text (Verified that JSON text is indeed being returned), but the callback is never executed (Based that nothing executes within the callback function and I don’t receive errors with bad JavaScript).
In my jsp file:
function getUserText(str)
{
$.getJSON("selectUser.htm", { id: str }, function(user)
{
//Doesn't matter what's here
});
}
In my controller:
@RequestMapping(value="/selectUser.htm")
public @ResponseBody String SelectUser(@RequestParam String id)
{
Users user = userMap.get(id);
if (user == null)
return null;
return createUserJSON(user);
}
Found the answer. Turns out that the JSON needs to be valid. I made a mistake so the JSON wasn’t formatted correctly. I didn’t know that the format mattered even before the callback function.