CAML query to get items from SharePoint 2013 list

I am attempting to get certain items from a list in SharePoint 2013 by using CAML query, once set to variables these item are to be called to a custom form to populate fields. I have set an alert in the SPServices Call and even it is not working, any direction would be helpful.

function GetUsers()
{
        //The Web Service method we are calling, to read list items we use 'GetListItems'
        var method = "GetListItems";
       
        //The display name of the list we are reading data from
        var list = "EmployeeData";

     
        var fieldsToRead =     "<ViewFields>" +
                                "<FieldRef Name='EmployeeID' />" +
                                "<FieldRef Name='FirstName' />" +
                                "<FieldRef Name='LastName' />" +
                            "</ViewFields>";
                           
       
        var query = "<Query>" +
                        "<Where>" +
                            "<Neq>" +
                                "<FieldRef Name='EmployeeID'/><Value Type='Number'>0</Value>" +
                            "</Neq>" +
                        "</Where>" +
                        "<OrderBy>" +
                            "<FieldRef Name='EmployeeID'/>" +
                        "</OrderBy>" +
                    "</Query>";
alert(query);
        //Here is our SPServices Call where we pass in the variables that we set above
        $().SPServices({
                operation: method,
                async: false,  //if you set this to true, you may get faster performance, but your order may not be accurate.
                listName: list,
                CAMLViewFields: fieldsToRead,
                  CAMLQuery: query,
                      //this basically means "do the following code when the call is complete"
                    completefunc: function (xData, Status) {
                        //this code iterates through every row of data returned from the web service call
                        $(xData.responseXML).SPFilterNode("z:row").each(function() {
                            //here is where we are reading the field values and putting them in JavaScript variables
                           
                         
                            //get the title field (ID)
                            var empNumber = ($(this).attr("ows_EmployeeID"));
                            //get eployee first name
                            var empFname = ($(this).attr("ows_FirstName"));
                            //get emplyee last name
                            var empLname = ($(this).attr("ows_LastName"));
                         
                      alert(empNumber);                            
                        });                
                    }
        });

}
cbridgesazAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IsaacSharePoint Client Side DeveloperCommented:
What error do you get?
0
cbridgesazAuthor Commented:
There is no error reported, and the alert does not show. Everything looks right to me but nothing happens.
0
IsaacSharePoint Client Side DeveloperCommented:
Are the spservices and jquery libraries uploaded?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

cbridgesazAuthor Commented:
Yes they are.
0
IsaacSharePoint Client Side DeveloperCommented:
Your alert is not firing because it's not recognizing the libraries.  Make sure the path to the files are correct.

Also, when you call the function is the file name correct?

Can you show a little bit more of your code?
0
cbridgesazAuthor Commented:
The libraries are : <link  type="text/css" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/start/jquery-ui.css" />
<!-- Reference jQuery on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Reference jQueryUI on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<!-- Reference SPServices on cdnjs (Cloudflare) -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.2/jquery.SPServices-0.7.2.min.js"></script>

and the function is called by $(document).ready(function(){
GetUsers();
});

Also, if I change "<FieldRef Name='EmployeeID/'>" to "<FieldRef Name='ID/'>" I get an alert that reads undefined
0
cbridgesazAuthor Commented:
I have found the solution!! I was importing a table from excel into SharePoint and using the query to retrieve data from the created list. The problem is that the headers from the table had spaces, and it was these columns that the CAML query had trouble with.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IsaacSharePoint Client Side DeveloperCommented:
Ahhhh......good catch!  I'm glad you found the solution!
0
cbridgesazAuthor Commented:
I started by trying to read another list that was manually created in SharePoint designer and the code worked, I then noticed that only difference other than one being exported from excel was the manually created list had single word columns and no spaces.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.