I see that the above question was asked earlier, however, even after their appeal, I could not find a way for me, so I took the liberty of starting a new post for this question.
I have a getjson.html file containing the following code
<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $.getJSON("json_data.txt",function(result){ $.each(result, function(i, field){ $("div").append(field + " "); }); }); }); }); </script> </head> <body> <button>Get JSON data</button> <div></div> </body> </html>
Json_data.txt contains the following:
{ "firstName": "John", "lastName": "Doe", "age": 25 }
When I open the getjson.html file in the browser, it gives an error:
"XMLHttpRequest cannot load the file: // ..... Origin null not allowed Access-Control-Allow-Origin."
Someone Please suggest a simple solution regarding this, how can I make this possible.
PS: I am writing a web application on the go.
source share