Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#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:
Blocked by: Blocking:

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 (4)

comment:1 Changed 9 years ago by Rick Waldron

Component: unfiledajax
Owner: set to alexuyt@…
Status: newpending

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);
                            }
        });

comment:2 Changed 9 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

comment:3 Changed 9 years ago by jaubourg

Resolution: duplicate
Status: pendingclosed

comment:4 Changed 9 years ago by jaubourg

Duplicate of #8084.

Note: See TracTickets for help on using tickets.