SharePoint Foundation – Obtaining Error When Adding a Share Point (JSOM) During a CRUD Operation


        $ (document) .ready (function () {
getUserName ();
AddData ("JS title", "CRJ");



AddData function (newItemTitle, school_locationn) {
var listName = "Name of the school";
CreateListItemWithDetails (listName, _spPageContextInfo.webAbsoluteUrl, newItemTitle, school_locationn, function () {
console.log ("The new item was successfully created.");
}, a function () {
console.log ("Ooops, an error has occurred. Please try again.");
});
}

// CREATE operation
// listName: the name of the list from which you want to get items
// weburl: the URL of the website in which the list is located.
// newItemTitle: New title of the item.
// success: The function to execute if the call is sufficient.
// failure: function to execute in case of call failure
function CreateListItemWithDetails (listName, webUrl, newItemTitle, school_locationn, success, failure) {
var itemType = GetItemTypeForListName (listName);
var item = {
"__metadata": {"type": ItemType},
"Title": newItemTitle,
"Location of the school": school_locationn
};

$ .ajax ({
url: _spPageContextInfo.webAbsoluteUrl + "/ _api / web / lists / getbytitle (" + listName + ") / items",
type: "POST",
contentType: "application / json; odata = verbose",
data: JSON.stringify (item),
headers: {
"Accept": "application / json; odata = verbose",
"X-RequestDigest": $ ("#__ REQUESTDIGEST"). Val ()
}
success: function (data) {
success (data);
}
error: function (data) {
failure (data);
}
});
}

// Get metadata of the type of list item
function GetItemTypeForListName (name) {
returns "SP.Data." + name.charAt (0) .toUpperCase () + name.split ("") .join (""). slice (1) + "ListItem";
}

var fun1 = function () {


}


});

Sharepoint website site URL –
http: //xxxxxxxxx.win-xxxxx: 47699 /

After pressing F5 (Visual studion) while getting an error in the browser>

The list 'School name & # 39; does not exist on the site with the URL: http: //app-xxxxxxxxx.win-xxxxx: 47699 / SharePointAddIn1 & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;

I think the error is due to the URL of the application that is different from the URL of the site collection, but my question is: if so, how to fix it? As my application will be in a different URL.

Please help.
Thank you .