Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Write to list with anonymous access

$
0
0
<script type="text/javascript" src="http://wtch02112013002/SiteAssets/js/jquery.min.js"></script>
<script type="text/javascript" src="http://wtch02112013002/SiteAssets/js/spservices.min.js"></script>
<input type="button" value="Add Item" id="AddItem"/>
TITLE:<input type="text" id="txtTitle" />
BODY:<input type="text" id="txtBody" />
<script type="text/javascript">
    var ctx, list, item;
    $("#AddItem").click(function () {

        ctx = new SP.ClientContext("/");
        list = ctx.get_web().get_lists().getByTitle("Announcements");
        item = list.addItem();
        alert($("input[id*='txtTitle']").val() + ", " + $("input[id*='txtBody']").val());
        item.set_item('Title', $("input[id*='txtTitle']").val());
        item.set_item('Body', $("input[id*='txtBody']").val());

        item.update();

        ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed);
    });

    function onQuerySucceeded() {
        alert('Item created: ');
    }

    function onQueryFailed(sender, args) {
        alert('Request failed. ');
    }
</script>
And clark1eh, you can get that View list to work if you run some powershell script to change the Web Application blocked types. You can do a search for that. I ran into that in an earlier search.

Dan

Viewing all articles
Browse latest Browse all 6517

Trending Articles