//
Blockquote I am trying to access the json contents through a Web API. I can access the contents but for some reason it gives me errors : "no 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
'http://localhost'
is therefore not allowed access." Now it means that I have to enable some how the CORS or by moving the contents to the same domain.I am not sure if I have to enable it On a: Origin Server (Requesting) in this case localhost b: On the external server OR c: I have to set up some code in my ajax call
Please advise and guide to right content as I am a bit of ******* in this regard.
<script>
jQuery(document).ready(function() {
jQuery('#34f8l4frywio').change(function(){
if((jQuery("#34f8l4frywio").length < 0) || (jQuery("#vnkt3fpocr10").length < 0)){
}else{
var newserial = jQuery("#34f8l4frywio").val();
var newmodel = jQuery("#vnkt3fpocr10").val();
jQuery.ajax({
url : 'http://example.com/xmlrpc/serial_json.php?serial='+ newserial+'&model='+ newmodel + '&format=json',
dataType: "text",
contentType: "text/plain",
xhrFields: {
withCredentials: false
},
//here it fails and gives the error
success: function(data) {
var json = $.parseJSON(data);
jQuery('#6bun045yhogr').val(json[0].warranty);
jQuery('#34f8l4frywio').val(json[0].serial);
jQuery("#vnkt3fpocr10").val(json[0].model);
}
});
}
});
});
</script>