JQuery error after upgrading to 4.1

Posted by Community Admin on 03-Aug-2018 18:10

JQuery error after upgrading to 4.1

All Replies

Posted by Community Admin on 20-Apr-2011 00:00

Hi,

I have a javascript function that calls a webmethod using ajax calling.
After upgrading to Q1, the webmethod calling url changes to append "?callback=jQuery151017602539529474603_1303318328937"

And the ajax call failed and throws the error attached in "Error.png".
Also the code can be found in "JavascriptSnippet.png"

Do you have any idea for this issue please?

Thanks.

Posted by Community Admin on 20-Apr-2011 00:00

Hmmm, with that callback appended I would assume it would need to be jsonp?

Posted by Community Admin on 20-Apr-2011 00:00

Thanks Steve for the reply,
I tried to change the data type to jsonp, I got an error "Missign 'parameter1' "
The webmethod can't get the parameters sent.

Any suggestions please?

Thanks.

Posted by Community Admin on 20-Apr-2011 00:00

Yeah I think it;s a little more involved for jsonp

var callbackurl = getAlfrescoServiceURL() + "&callback=?"; //Get the full URL for the alfresco feed
 
        //set defaultval on param
        if (param == null || param == "")
            param = "none";
 
        //CLEAR
        resetmediaitems();
 
        //initate ajax callback to get the lecture items
        $.getJSON(callbackurl, "param=" + $.trim(param), function (data)
            //delete the loading panel
            $(".loadingpanel").remove();
 
            if (data.mediaitems.length > 0)   //Make sure we only loop if there's items
                createListLayout(data); //Gets a list view of the data
            
 
            //Create the Pager
            var count = data.mediaitems.length;
            $("#pager").ajaxPager( startPage: 1, PagesCount: 1, ChangeSiteEvent: PageClick );
 
            firstLoad = false;
        );

This is a snippit from something else I'm calling with jsonp...so the idea is the return value specifies the function name the javacsript will run (the callbackurl).

Doc

Posted by Community Admin on 20-Apr-2011 00:00

Hi Steve,
I used getJSON function, the webmethod url changed to "localhost:53653/.../AddToFavorities&callback=jQuery15108446318376319131_1303328595466
and I got "400 bad request error"

Thanks

Posted by Community Admin on 20-Apr-2011 00:00

Looks like you have a querystring problem there

First param should start with a ? then the others are &

In my sample I already have a couple in the getAlfrescoServiceURL() :o  Sorry about that

So should be something like

AddToFavorities?callback=jQuery15108446318376319131_1303328595466&favorities=185&_=1303328634562
(is the underscore valid as a querystring key?)

Posted by Community Admin on 20-Apr-2011 00:00

sorry Steve, 

this is the url of the webmethod "localhost:53653/.../AddToFavorities

and this is the javascript code "$.getJSON("/Services/WebServices.asmx/AddToFavorities", "favorities=185", function (data) alert(data) );"

Posted by Community Admin on 21-Apr-2011 00:00

I am not using cross domain requests, using json not jsonp, so why the "?callback=" is appended to the url?
and why I got this issue after upgrading to Q1?

Thanks.

Posted by Community Admin on 21-Apr-2011 00:00

Thanks guys, I resolved the issue.

It was about an issue in JQuery validation plugin v1.7, it changes the ajax behavior to be jsonp instead of json.
http://www.victorocastro.com/2011/02/26/jquery-1-5-converting-json-to-jsonp-for-local-requests-what-the-219/

Thanks.

This thread is closed