Wednesday 2 October 2019

javascript - jQuery Ajax error: 'null' has been blocked by CORS policy

I have to make a game, which gives the definition of a word and you have to guess it. It gives me an error while making an Ajax request:



jquery-3.2.1.js:9566 Access to XMLHttpRequest at 'file:///D:/Grado%20Superior/2do/DWEC/logogrifo_CristinaBorrego/logogrifo.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

send @ jquery-3.2.1.js:9566
ajax @ jquery-3.2.1.js:9173
jQuery.(anonymous function) @ jquery-3.2.1.js:9322
getJSON @ jquery-3.2.1.js:9303
(anonymous) @ index.html:44
jquery-3.2.1.js:3860 jQuery.Deferred exception: Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined
at HTMLDocument. (file:///D:/Grado%20Superior/2do/DWEC/logogrifo_CristinaBorrego/index.html:55:62)
at mightThrow (https://code.jquery.com/jquery-3.2.1.js:3583:29)
at process (https://code.jquery.com/jquery-3.2.1.js:3651:12) undefined
jQuery.Deferred.exceptionHook @ jquery-3.2.1.js:3860

process @ jquery-3.2.1.js:3655
setTimeout (async)
(anonymous) @ jquery-3.2.1.js:3689
fire @ jquery-3.2.1.js:3317
fireWith @ jquery-3.2.1.js:3447
fire @ jquery-3.2.1.js:3455
fire @ jquery-3.2.1.js:3317
fireWith @ jquery-3.2.1.js:3447
ready @ jquery-3.2.1.js:3920
completed @ jquery-3.2.1.js:3930

jquery-3.2.1.js:3869 Uncaught TypeError: Cannot read property 'length' of undefined
at HTMLDocument. (index.html:55)
at mightThrow (jquery-3.2.1.js:3583)
at process (jquery-3.2.1.js:3651)


My code:












Logogrifo




Logogrifo












src="https://code.jquery.com/jquery-3.2.1.js"
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
crossorigin="anonymous">





No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...