JQuery error after upgrading to 4.1
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.
Hmmm, with that callback appended I would assume it would need to be jsonp?
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.
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
;
);
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
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?)
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) );"
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.
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.