I am learning sharepoint 2013 and trying to add items from web part. Below is my code. After I click submit button no error is shown but no item is added to the list. I have been trying my whole day to find out what is the problem but I could not figure it out. Please help.
<script src="/ss14/14ss-55555/_layouts/15/l2passets/js/jquery.js" unselectable="on"></script>
<script src="/ss14/14ss-%2055555/_layouts/15/l2passets/js/SPServices.js" unselectable="on"></script>
Email <input name="email" id="email" type="text"><br unselectable="on">
Country<input name="country" id="country" type="text"><br unselectable="on">
<input value="Submit" onclick="addItem()" type="submit">
<script unselectable="on">
var emailVal = $('#email').val();
var countryVal = $('#country').val();
function addItem(){
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "Share Point List",
valuepairs: [["Email", emailVal], ["Country", countryVal]],
completefunc: function (xData, Status) {
alert("Data Saved! and Please check your List");
}
});
}
</script>
If you are learning SharePoint 2013, I would recommend learning to do this with the JavaScript APIs first instead of relying on 3rd party tools that may or may not work correctly.
Here is a link to some basic list operations using the CSOM from MSDN https://code.msdn.microsoft.com/SharePoint-2013-Perform-eba8df54