last day (14 days later) » 

2:34 PM
0
A: Using jQuery to build table rows from Ajax response (not with static json data)

Corey YoungMake sure the headers are set to JSON in your PHP. Verify that the response variable has the structure you are expecting as well. It could be an issue with the structure creation in the php. Sometimes json_encode does something different than what you expect. to console log the repsonse put it h...

 
json structure is as I wanted. getjson.php works fine if I call it from browser. I just can't create table with dynamic json data.
 
what happens when you console.log(response) from getjson.php and from static. is there a difference there?
 
Afer which line should I write it? I have tried some lines but none of them returned anything.
 
I added it to my answer
 
Thanks. I tried that before and called the showjson.php (which is the file that I want to create table and contains the code I wrote above) but nothing happens if I'm doing right. Do I need firebug or something?
 
2:34 PM
Yes you need some sort of debug tools with a console. all major browsers have one installed by default. f12 will bring it up. then look for something called console. You will see your console log displayed there with the data. Use this to see the difference between the code. If there is one please post both to the question and we can take it from there
 
ok thanks for the info. i added updated information in my main question. please look for update section
 
what do you see when you put this console.log(typeof(response));
 
just this: jquery-1.11.3.js:577 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in

{"kullanicilar":[{"id":"6","konu":"blood angels","aciklama":"primarch","giris_tarih":"0000-00-00","degistirilme_tarih":"0000-00-00","ad_soyad":"singuinius","email":"warhammer"},{"id":"7","konu":"emperors children","aciklama":"daemon primarch","giris_tarih":"0000-00-00","degistirilme_tarih":"0000-00-00","ad_soyad":"fulgrim","email":"warhammer"},{"id":"8","konu":"night lords","aciklama":"primarch","giris_tarih":"0000-00-00","degistirilme_tarih":"0000-00-00","ad_soyad":"konrad curze","email"
 
that is the error that is stopping your code the console log should say something like 'string' or 'object'
do you need the key "kullanicilar"
could the structure be
[
{
"id":"6",
"konu":"blood angels",
"aciklama":"primarch",
"giris_tarih":"0000-00-00",
"degistirilme_tarih":"0000-00-00",
"ad_soyad":"singuinius",
"email":"warhammer"
},
{
"id":"7",
"konu":"emperors children",
"aciklama":"daemon primarch",
"giris_tarih":"0000-00-00",
"degistirilme_tarih":"0000-00-00",
"ad_soyad":"fulgrim",
"email":"warhammer"
},
{
"id":"8",
"konu":"night lords",
"aciklama":"primarch",
"giris_tarih":"0000-00-00",
"degistirilme_tarih":"0000-00-00",
"ad_soyad":"konrad curze",
"email":"warhammer"
so that the main key is just something generic like data
this way you can just do a simple loop through the data like
for(var i = 0; i < response.data.length; i++){
then you can do response.data[i].id , repsonse.data[i].email and so forth
I have updated my answer
 
2:59 PM
thank you i will try it later today. now im must leave. i will update you. thank again
 

last day (14 days later) »