I am trying to post form data to NetSuite restlet using jQuery ajax. Using below code to post data to NetSuite restlet OAuth1.0.
jQuery(".form-button").click(function(){
jQuery.ajax({
url: "https://tstdXXXXXX.restlets.api.netsuite.com/app/site/hosting/restlet.nl?
script=XXXX&deploy=1",
type: "POST",
crossDomain: true,
dataType: "jsonp",
mode: 'cors',
contentType: "application/json",
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "NLAuth nlauth_account=ACCOUNT#,
nlauth_email=EMAIL, nlauth_signature=XXXXXX, nlauth_role=ROLE#")
}
})
.done(function(data){
console.log(data);
});
});
after using above code initially I got error "http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present" . To fix this i have added mode "cors". Now I am getting ERR_ABORTED 401.
Thanks in advance