I wanted to get the json code on this page .
This is the the JSON code:
[{"idStore":"13","0":"13","Name":"1414141414144","1":"1414141414144","Phone":"123456","2":"123456","Email":"tretretr","3":"tretretr","Description":"aaaaaaaaaaaa","4":"aaaaaaaaaaaa","Ville":"zaeazezae","5":"zaeazezae","Address":"aaaaaaaaaaaaaaaaaaaaaa","6":"aaaaaaaaaaaaaaaaaaaaaa","MsPoint":"0","7":"0","idGenre":"14","8":"14","Image":"--","9":"--","Country":"zaeaze","10":"zaeaze","idUser":"21","11":"21","Lat":"0","12":"0","Lng":"0","13":"0"}]
I have no knowledge of ajax so i tried to parse the content of the output of the php file into result.json
.
$fp = fopen('result.json', 'w');
fwrite($fp, json_encode($stores));
fclose($fp);
I used this ajax code to read my result.json
file since the script is not on the same page with the JSON output.
This is my www
folder architecture:
www -> js -> app.js
-> inedx.php
-> Store.php
-> result.josn
I am using app.js
to load the data from the JSON file (created by the Store.php
) and modify it. Then I use it in index.php
.
var da = $.ajax({
url: "../result.json",
success: function (data) {
var obj = JSON.parse(data);
}
});
alert(da);
And the output was:
[Object Object]
Did i miss something?