I am trying to get my blog posts by using JSOM, following is my code to get personal_site/blog which generates "unexpected response data from server", when I debug the JavaScript it shows "Access Denied". (my personal site located on another web application).

  bolagContext = new SP.ClientContext(url);

  var oList = bolagContext.get_web().get_lists().getByTitle('Posts');

  var camlQuery = new SP.CamlQuery();
  camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name=\'Created\' Ascending=\'False\' /></OrderBy></Query><FieldRef Name=\'Title\' /><FieldRef Name=\'ID\' /><FieldRef Name=\'Created\' /><RowLimit>2</RowLimit></View>');
  collListItem = oList.getItems(camlQuery);


  Function.createDelegate(this, function (sender, args) {

   //go through items
Function.createDelegate(this, function (sender, args) {

  alert(args.get_message()); // says: unexpected response data from server".

I have tested the code to get another list on another site and it worked.

1 Answer 1


JSOM only works within the scope of a site collection. To fetch data from a different web application you'll have to use the REST interface or Lists.asmx and pass your credentials along with the request.

  • thank you, now I am using REST when I run my query on browswer it works but it generates this error in my javascript code. Error: Invalid field or parameter requestInfo.url. I am not using apps usual javascript file and var executor = new SP.RequestExecutor(_spPageContextInfo.webAbsoluteUrl);
    – Medes
    Commented Jun 4, 2013 at 15:40
  • ask a new question, post your code to it, and explain what you're expecting, and what you're getting. Commented Jun 4, 2013 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.