I'm extremely new to SharePoint and was recently experimenting with the client side object model. I've used one of MSDNS examples. however, I seem to be getting this error response :
"request failed. Unexpected Response from server.The status code of the response is '0'. The status text of the response is null"
Here is the sample of the code I've used:
function retrieveListItems() {
var siteUrl = '/personal/amgu/workspace/music/'; // music is a site within a site.
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('Music');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'Title\'/>' +
'<Value Type=\'Text\'>'+Title+'</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>'); // trying to query using the title name which is unique and I've retrieved and stored it in a variable called title.
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo += '\nID: ' + oListItem.get_id() +
'\nTitle: ' + oListItem.get_item('Title') +
'\Votes: ' + oListItem.get_item('Votes'); // this is another column to which i actually want to make an increment after getting the previous value first
}
alert(listItemInfo.toString());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
Please tell me is there something wrong with my CAML query?
Note: 1.)the function is being triggered via a button click, Bound to it via jquery bind.
2.) Also happened to notice this in the Console as soon as i click the button:
NS_ERROR_NOT_AVAILABLE: prompt aborted by user .... nsPrompter.js
(this error comes immediately after clicking)
Would really appreciate it if someone could throw some light onto the matter hehe.
3.) removed the CAML query function from the code and then tried . Still gave the same error
4.)BUTTON MARKUP:
I've plugged in the vote up and vote down buttons inside the web part title
$("#WebPartTitleWPQ3").html(Title + ".mp3 : By " + Artist + "   (" + Votes + " votes) ").css("font-size", "20px").append("<button id='voteBtnUp' > Vote Up </button> <button id='voteBtnDn' > Vote Down </button>");
and the bound the click handler to them like this
$('#voteBtnUp').bind("click", function () { voteOnClick(Title, "up"); });
$('#voteBtnDn').bind("click", function () { voteOnClick(Title, "Dn"); });
voteOnClick si simply calling the retrieveListItems() functions for now. haven't used the arguments for anything
Also, tried using get_web() instead while creating the client context, still not working