Need help with JQuery AJAX Call

Need help with JQuery AJAX Call

Hi,

I am making a call to rest service from java script. Rest service is working fine . I have tested it from curl. Rest service takes string and return string. When Add button is clicked it always shows ERROR alert in chrome and rest service is invoked. When tested from firefox call is never made to rest service. Please also provide help on handling error.

HTML -> 



Java Script -> 

var rootURL = "http://localhost:8084/rest/hi";





$('#url_submit').click(function() { 
      addByURL($('#urlvalue').val());   
}); function addByURL(urlval) {             console.log('urlval: ' + urlval); $.ajax({ type: 'POST', contentType: 'text/plain', url: rootURL , dataType: "text",                 data:urlval,                 success: function (data) {                     console.log(data);                     alert('Cert created successfully'+ data);                 },                 error: function (data) {                     //alert('ERROR:textStatus:'+ textStatus + " errorThrown:" + errorThrown + " jqXHR:" + jqXHR);                     //alert('ERROR:' + data);                      console.log(data);                     alert("ERROR");                 }    }); }