Getting a "bad label" error in jQuery calling a WCF service

I am uisng JQuery 1.3.2 and have problems with something that usually worked.

I am calling the WCF service in a different domain. My call hits my service and returns a valid JSON object, but I continue to receive this "invalid label" error.

var url = "http://.../GetEmployee?callback=?";

$.getJSON(url2,{empolyeeNo:42}, function(data) { alert("works!"); });

http: //.../GetEmployee? callback = jsonp1246048506475 & _ = 1246048755308 & echoThis = 42

The answer I see in the Firebug console is:

Firebug log limit reached. % S no entries shown. Invalid settings shortcut [Break on this error] {"d": "You sent this 42"}

Does anyone know what I can do wrong? I was around and showed this to a couple of jQuery guys. No one seems to know what the problem is.

Full disclosure: the application is a .NET 3.5 w / WCF server and an ASP.NET MVC application.

Thanks,

+3
source share
1 answer

WCF / ASP.NET intentionally returns a JSON string that you cannot call eval because eval on JSON calls is unsafe and leaves you open to capture JSON, you should use the JSON parser p>

If you want to leave yourself vulnerable and still use eval, you can wrap it

var response = eval( '(' + jsonString + ')' );

But really, use a parser .

+3
source

Source: https://habr.com/ru/post/1711375/


All Articles