This project has moved. For the latest updates, please go here.

GetLisItems inside a Function on Sharepoint 2013

Mar 15 at 8:20 AM
Edited Mar 15 at 8:22 AM
I am having problem in getting the ID using the GetListItems operation.
I have been going through lots of example.
Even with a simple example, I am not able to make it work. Seriously now I am stuck.

To return an ID of an item if a value matches a value in one of the column in the list.

Below is my code.
$(document).ready(function() {
function insert()
var queryLookup = "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>"12345"</Value></Eq></Where></Query>";
var itemID="";
var thisID="";
    operation: "GetListItems",
    async: false,
    listName: "Sunway Construction Staff",
    CAMLViewFields: "<ViewFields><FieldRef Name='ID'/></ViewFields>",
    CAMLQuery: queryLookup,
    completefunc: function(xData,Status) { 
        itemID = $(xData.responseXML).SPFilterNode("z:row").each(function() {
            thisID = ($(this).attr("ows_ID"));
   alert("Item ID is="+itemID);
   alert("This ID is="+thisID);
The alert(thisID); and alert(itemID); does not seem to fire up.
But the alert("This ID is="+thisID); and alert("Item ID is="+itemID); is firing up but with no value.

Does the SPServices part not running?
Or am I wrong at a lot of level?

Thank you.