Hi everyone. Anyone here tried to access netsuite...
# suitescript
b
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."
f
You have a couple of options. playing around with the headers https://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy implementing JSONP , or just using a PHP page to bounce the request/response.
b
is there any way to send data using jquery ajax?
your suggestion would be greatly appreciated. thanks