none
Firefox cannot update list item by javascript RRS feed

  • Question

  • Hi 

    I am update the SharePoint list item by javascript as below code:

    -----------------------------------------------------------------------

        var clientContext = SP.ClientContext.get_current();
        var oList = clientContext.get_web().get_lists().getByTitle("Document");
        var oListItem = oList.getItemById(1);


        oListItem.set_item('Status', "complete");
        oListItem.update();

        clientContext.executeQueryAsync(
            Function.createDelegate(this, this.onQuerySucceeded),
            Function.createDelegate(this, this.onQueryFailed)
        );

    -----------------------------------------------------------------------

    I try it in ie and chrome and both of them are return true.

    But I it return false in firefox and through the error message in below:

    (Unexpected response from server. The status code of response is '0'. The status text of response is ''.
    null)

    Any idea in this issue?

    Thanks

       
    Tuesday, March 22, 2016 11:56 AM

Answers

  • Hi,

    Please try to update your Firefox to test.

    I have tested in my environment using Firefox and it works fine. The code I tested for your reference:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script><script type="text/javascript">
    
    
    _spBodyOnLoadFunctionNames.push("callCSOM");
    
    
    var clientContext;
    
    var website;
    
    var item;
    
    var str="";
    
    
    // Make sure the SharePoint script file 'sp.js' is loaded before your
    
    // code runs.
    
    function callCSOM()
    
    {
    
           ExecuteOrDelayUntilScriptLoaded(sharePointReady, "sp.js");   
    
    }
    
    
    // Create an instance of the current context.
    
    function sharePointReady() {
    
        clientContext = SP.ClientContext.get_current();
    
        website = clientContext.get_web();
    
        var list = website.get_lists().getByTitle('Document');
    
        item = list.getItemById(1);
    
        item.set_item('Status', "complete");
    
        item.update();
    
        clientContext.load(item);
    
        clientContext.load(website);
    
        clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
    
    }
    
    function onRequestSucceeded() {
    
        //console.log("website.get_title(): "+website.get_title());
    
        //console.log("Item Title: " + item.get_item("Title"));
    
           
    
    }
    
    function onRequestFailed(sender, args) {
    
        alert('Error: ' + args.get_message());
    
    }
    
    </script>
    

    It would be helpful to us to try to reproduce your issue and resolve it if you can provide the whole code.

    Thanks,

    Dean Wang


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Marked as answer by Kit2607 Wednesday, March 23, 2016 8:15 AM
    Wednesday, March 23, 2016 7:50 AM
    Moderator