javascript - How to make jquery objects of array from php response of ajax call -


here javascript variable my, wanted php file.

inside selectannotation.php echoing

echo "{     src : 'http://192.168.1.58/annotate/drive/image/test.jpg',     text : 'suresh , gopinath....',     shapes : [{         type : 'rect',         geometry : { x : 0.1825726141078838, y: 0.23756906077348067, width : 0.11602209944751381, height: 0.11618257261410789 }     }] }"; exit; 

as, wanted php file. achieve made ajax call

    var = {     src : 'http://192.168.1.58/annotate/drive/image/<?php echo $_get['file']?>',     text : 'suresh , gopinath....',     shapes : [{         type : 'rect',         geometry : { x : 0.1825726141078838, y: 0.23756906077348067, width : 0.11602209944751381, height: 0.11618257261410789 }     }] } console.log(my); console.log('__________');     $.post("mastercall/selectannotation.php",         { url: 'http://192.168.1.58/annotate/drive/image/<?php echo $_get['file']?>'         },         function(data,status){         console.log(data);         console.log('__________');         //anno.addannotation(data);         }); 

while doing this, can see difference in console..

here screen of happens console log of console.log(my) , console.log(data)

enter image description here

so, how can make proper response appears inside console.log(my)

note :

the var my proper format need, wanted same format posted php file , in jquery.

update :

when try

$v = "{     src : 'http://192.168.1.58/annotate/drive/image/test.jpg',     text : 'suresh , gopinath....',     shapes : [{         type : 'rect',         geometry : { x : 0.1825726141078838, y: 0.23756906077348067, width : 0.11602209944751381, height: 0.11618257261410789 }     }] }"; echo json_encode($v); 

and in jquery

function(data,status){         var obj = jquery.parsejson( data);         console.log(obj);         }); 

i getting same previous one..

try constructing this:

$result = $connection->query($query);  $result=array();  $i=0;  while($row = $result->fetch_assoc()){  $result[$i]['src']=$row['src'];  $result[$i]['text']=$row['text'];   $result[$i]['shapes'][]=array('type'=>'rect','geometry'=>array('x' => $row['x'], 'y'=> $row['y'], 'width' => $row['width'], 'height'=>$row['height']) );  $i++;  }  echo json_encode($result); 

//javascript response after success...

data=json.parse(data);  for(var i=0;i<data.length;i++){  console.log(data[i]);  } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -