Hi everyone.
Anyone here tried to access netsuite RESTLET via jquery??
I have this JSON object extracted from an javascript file uploading and Im trying to send the object using Jquery AJAX in Netsuite via RESTLET.
Below is my Jquery Ajax Script
$.ajax({
type: 'GET',
url: URL,
dataType:'json',
crossDomain : true,
beforeSend: function(xhr) {
xhr.setRequestHeader('Access-Control-Allow-Origin','*');
xhr.setRequestHeader('Access-Control-Request-Method','GET, POST');
xhr.setRequestHeader('Access-Control-Request-Headers','*');
xhr.setRequestHeader('User-Agent-x','SuiteScript-Call');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', EXAMPLE CREDENTIALS);
},
success: function (response) {
console.log(response);
},
error: function(xhr, textStatus, errorThrown) {
console.log(textStatus+' : '+ errorThrown + ' : '+JSON.stringify(xhr));
}
});
Im getting this error "Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."