Adding comments to blog via SPServices

Jul 12, 2014 at 8:36 PM
In an effort to provide a bit more customization and cleaner look and feel along with all the other goodies that SPServices provides, I've been trying to get a custom comment submission from a home page that provides teaser blog entries for quick and increased collaboration.

However, in trying to post to the Comments list on the blog subsite (I believe they have the Bamboo Discussion Board Plus feature enabled), I get tje following error in the response SOAP:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="">Cannot access a closed Stream.</errorstring></detail></soap:Fault></soap:Body></soap:Envelope>
I've used a similar way to write to other lists for quite a while, but here's the code currently in development for this. I've added a few extra comments inline for clarification/context
// Sends in id of blog post as well as the title of the post entry, URI encoded.
//I have to escape and send in encoded for ' and other special characters, which would break in the javascript
function commentPopup(id, entry){
    //URI decode the post title and display in label div tag

    //reset the text area for comments to blank to allow user to enter their comment
    $("#divCommentForm textArea").val('');

    //show modal popup to enter comments

function submitComment (){
    //grab user's comments
    comment = $("#divCommentForm textArea").val();

    //hide the form, then do the upload

    //if there was a comment, show a 'thank you' message, then upload the comment
    if (comment){        

function uploadComment(comment){
    //grab comment and pass into XML function to setup for SPService to add
    var updateCommentXml = get_UpdateCommentXML(comment);
    //testing alert to make sure correct XML format and data was made
        webURL: "/Blog",
        operation: "UpdateListItems",
        async: true,
        listName: "Comments",
        updates: updateCommentXml ,
        completefunc: function(xData, Status) {
            //this is where the error response keeps coming back instead of actually creating the new comment

function get_UpdateCommentXML(comment){
    var xml = '';

    xml ='<Batch OnError="Continue" ListVersion="1">';
    xml +=  '<Method ID="1" Cmd="New">';
    xml +=  '<Field Name="Title">Comment</Field>';
    //Tried with and without CDATA to see if it would help escape other characters
    xml +=  '<Field Name="Body"><![CDATA["' + comment + '"]]></Field>';
    //Used hard coded ID and Titles as well as blank, both came back with errors
    xml +=  '<FieldRef Name="PostID" />';
    xml +=  '<FieldRef Name="PostTitle" />';
    xml +=  '</Method>';
    xml += '</Batch>';

    return xml;
Aug 20, 2014 at 2:27 AM
Try async: false and see if that works. Otherwise, you should probably switch to using promises. Also look at the Net traffic in Firebug or Fiddler.