I’ve got a bit of javascript that I’m using to add a list item to a list. It is working in IE, Chrome, Opera, and FireFox. But Safari is the lone browser causing me grief. Any ideas on this rather strange error? I have scoured the web today and found only one vague mention of the problem on this site:
http://www.threewill.com/2013/07/lessons-learned-about-bringing-a-sharepoint-app-to-mobile/
And his suggestion was to use SetTimeout (doesn’t describe how he’s doing it exactly) in order to overcome Safari issues on mobile devices. My scenario does not address mobile – only desktop browser use.
Any help would be appreciated. Below is my code:
/*Create a new list item in MyLinks list*/
function AddMyLink(url, desc){
this.clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle(‘MyLinks’);var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);var urlValue = new SP.FieldUrlValue();
urlValue.set_url(url);
urlValue.set_description(desc);oListItem.set_item(‘URL’, urlValue);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(
function(sender,args){
//console.log(‘Item created: ‘ + oListItem.get_id());
GetMyLinks();
var statusid = SP.UI.Notify.addNotification(‘Your link was successfully added.’);
},
function(sender,args){
var statusid = SP.UI.Notify.addNotification(‘We couldn\’t add your link for some reason. Please refresh the page and try again.’);
console.log(‘Request failed. ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());
}
);}
I just read entire problem of yours, that you are facing by using Safari Browser & i would like to help you by providing some suggestion. If you are getting any kind of issue while using safari browser then i would like to recommend read Safari Can’t Establish a Secure Connection blog to get proper guideline which helps you to resolve your problem.
Thanks for checking it out Shelly. It turns out that the limitation occurs only on Safari for Windows, but runs perfectly on a Mac.
Never trust an Apple product on a Windows machine!
I tested this function via console in both Chrome and Safari and it is working for me. I don’t have the code for your GetMyLinks() function, is it possible that’s the where the problem is originating? Does GetMyLinks include another call to executeQueryAsync? I have seen reference to issues with nested calls to executeQueryAsync.