Ticket #8454 (closed bug: duplicate)
Error with using method getJSON in jQuery 1.5.1
| Reported by: | alexuyt@… | Owned by: | alexuyt@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | ajax | Version: | 1.5.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I've used in my project jQuery 1.4.4, decided to move to version 1.5.1 and I have a problem with method getJSON.
My JS code:
$.getJSON("<s:url action="checkRegistryErrorsNumber" includeParams="none" />",
{"registry.id": <s:property value="registry.id" />},
function(data) {
$("#errorsNumber").text(data.errorsNumber);
if (data.errorMessage != "") {
$("#messagesBlock").html(data.errorMessage);
}
});
I'm using Struts 2.0.14 and you see some struts tags from jsp page. That is response:
<%@page contentType="application/json;charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
{
"errorsNumber": "<s:property value="registry.errorsNumber" />",
"errorMessage": "<s:actionerror />"
}
Using jQuery 1.4.4 - all OK Using jQuery 1.5.1 - error in FF : "Invalid label"
What has changed in the new version? Why the request has not working? Bug in jQuery?
Change History
comment:1 Changed 2 years ago by rwaldron
- Owner set to alexuyt@…
- Status changed from new to pending
- Component changed from unfiled to ajax
comment:2 Changed 2 years ago by altro
This was code from jsp-page with using struts taglib.
This is generated final code:
$.getJSON("/eirc/eirc/checkRegistryErrorsNumber.action",
{"registry.id": 131},
function(data) {
$("#errorsNumber").text(data.errorsNumber);
if (data.errorMessage != "") {
$("#messagesBlock").html(data.errorMessage);
}
}
);
This is response content in Chrome:
{
"errorsNumber": "157714",
"errorMessage": ""
}
This is error in Chrome:
Uncaught SyntaxError: Unexpected token :
d.d.extend.globalEvaljquery-1.5.1.min.js:16 d.ajaxSetup.converters.text scriptjquery-1.5.1.min.js:16 bQjquery-1.5.1.min.js:16 vjquery-1.5.1.min.js:16 d.support.ajax.d.ajaxTransport.send.cjquery-1.5.1.min.js:16
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Is this some kind of template code? If not, then you'll need to provide a reduced test case, because this code is full of syntax errors.
$.getJSON("<s:url action="checkRegistryErrorsNumber" includeParams="none" />", {"registry.id": <s:property value="registry.id" />}, function(data) { $("#errorsNumber").text(data.errorsNumber); if (data.errorMessage != "") { $("#messagesBlock").html(data.errorMessage); } });