Using AJAX We can get php echoed data by
success: function(data)
Also We can point them to display inside any ware in the page using id of the element. Eg-
$("#id").html(data);
My problem is how can I display those data in different places? My result gives me like 8 values and I want them to display in different places of my web page. Better if i can use php codes where ever i want to display them. eg:- <?php echo ($row[0]); ?>
<?php echo ($row[0]); ?>
I'am sure it is possible with PHP Sessions. Is there an easy way to achieve this?
Define a global variable and assign returned json to that variable then you can use that value anywhere in the page.
Var datarow;
$.ajax({
...,
success: function(dataJson) {
datarow=dataJson
}
});
$("#yourHtmlId").html(''+datarow.firstValue);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.