jquery 1.7.2. spservices Syntax error, unrecognized expression: [nodeName=z:row]

3.3k Views Asked by At

Getting Syntax error, unrecognized expression: [nodeName=z:row] on this code.

<script type="text/javascript" src="https://.../jquery.js"></script> 
<script type="text/javascript" src="https://..//spservices.js"></script> 
<script>
$(document).ready(function(){
 var queryStringValues = $().SPServices.SPGetQueryString();
 var t = queryStringValues["Title"];
 var query = "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + t + "</Value></Eq></Where></Query>";
 var url = window.location;
 $().SPServices({
            operation: "GetListItems",
            listName: "ApprovalCustom",
            async: false,
            CAMLQuery: query,
            completefunc: function (xData, Status) {
                $(xData.responseXML).find("[nodeName=z:row]").each(function(){
                    id = $(this).attr("ows_ID");
                    url = $().SPServices.SPGetCurrentSite() + "/Lists/ApprovalCustom/DispForm.aspx?ID=" + id;
                    window.location = url;
                });
                }
        });
   });
2

There are 2 best solutions below

0
On

You need to quote the value of your attribute: .find('[nodeName="z:row"]') Always quote attribute values.

And don't use $() for XML-Data. Use $.parseXML(). http://api.jquery.com/jQuery.parseXML/

0
On

if you are using jquery 1.7 and above the syntax cannot work anymore, see jQuery Library for SharePoint Web Services (SPServices) v0.7.0 Beta 1. Please use $(xData.responseXML).SPFilterNode("z:row").each(function() { }); instead.