I'm running a SharePoint method with SPServices that should copy several items. I just noticed that the return value is "Success" even when I've specified an invalid location and nothing has actually happened. Since I can't use status, I noticed that the xdata.responsetext returns this:

<Results><CopyResult ErrorCode="Unknown" 
ErrorMessage="Object reference not set to an instance of an object." DestinationUrl="[someurlhere]" /></Results></CopyIntoItemsResponse>

I tried returning xdata.responseText.find("Results").text(); and was going to write a condition to see if it contains "ErrorMessage" (since I don't get this tag at all on valid destinations), but this doesn't return anything even though I'm able to return things like the 0 in "<CopyIntoItemsResult>0</CopyIntoItemsResult>". Is there an alternative method? I'm relatively new to jquery, so I'm hoping I'm making a novice mistake. FYI: The reason I'm using responseText instead of responseXML is because of an issue with jquery 1.9 where the xml is undefined with spservices calls by the way.

2 Answers 2


The following example demonstrates how to add error handling for CopyIntoItems operation in SPServices:

completefunc: function(xData, Status) {

     var errorCode = $(xData.responseXML).find('CopyResult').attr('ErrorCode');
     if (errorCode == "Unknown") {
          var errorMessage = $(xData.responseXML).find('CopyResult').attr('ErrorMessage');
          console.log ("Unable to copy item: " + errorMessage);


Please refer this thread for an great explanation why SPServices does not contain built in error handling:

There are two main layers where an error can occur:

  • In the AJAX call itself. This really only occurs if the endpoint (SharePoint) isn't responding, usually due to the server being down.
  • In the Web Service itself. Unfortunately there is almost zero consistency in the implementations. No two operations respond in
    quite the same way, and there nothing in common across the Web
    Services. The only commonality is that they return XML.

In all of my use of SPServices, I've found a few truths.

  • SharePoint always responds if it's up and running.
  • The only time a Web Service call fails is if you pass it bad data or poorly formed XML.
  • Thank you very much. It was the ".attr" piece I was missing. Commented Mar 18, 2014 at 13:11

In update or adding records you could use:


to check if some fields giving error.

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.