I have the following function in a .js file in index.html
function getValues(){
$.ajax({
type: 'POST',
url: "http://localhost/getData/getdata.php",
success: function(data){
var dataValues;
var apnd;
dataValues = String(data.NSE);
apnd = "a";
updateValues(dataValues, apnd);
dataValues = String(data.BSE);
apnd = "b";
updateValues(dataValues, apnd);
},
dataType: "json"
});
}
this works fine when I run it in a webserver like wamp. But I want to run index.html locally i.e without a webserver, The user just double clicks index.html and it should run but it doesn't. data is always null. What could be the problem? Sorry I am a super JQuery Noob.
the code in getdata.php file is
<?
echo json_encode(array("NSE"=>rand(5000, 20000),"BSE"=>rand(5000, 20000)));
?>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…