javascript - Using data from a PHP array in AJAX -


i'm making change way site works , trying find solution requires little re-writing possible.

at moment, have file (myfile.php) loads (using wordpress) page. uses php array outputting data. php array $property_list_featured_search , content looks this:

<?php      foreach($property_list_featured_search $individual_property){ ?>     <span><?php echo $individual_property['info']['status'] ?></span> <?php     } ?> 

so in small example, it's outputting data $property_list_featured_search , works ok.

my problem want load html&php above using jquery ajax. when user clicks button, loads html (which stored in file, called myfile.php div on page:

function loadview(view){         $.ajax({             type: "post",             url: 'path/to/file/property-search/myfile.php',             data: property_data,             success: function(result)             {                 $("#search-page-content").html(result);         });     } 

in case above, property_data $property_list_featured_search data localized using wordpress file can access it. have tested , can confirm file loaded in ajax able see data. problem have file php echo everywhere , data in json format.

is possible still use data in way? i'm guessing because data json it's not possible use echo $data[key] @ in original file?

what's best way output data in json file on page?

you can try this: when u data:

  $checked = $_post['property_data'];   $checked = array('first' => $checked[0], 'second' => $checked[1], 'third' => $checked[2], 'forth' => $checked[3]); 

then can echo this:

$checked['first'], $checked['second'] , on.  

hope helps


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -