javascript - PHP View-Controller-Class Model -
i have open ended question php view-controller-class model.
say, have perform logic loop in controller use method in class retrieve data row database.
however, @ time, can set 1 php variable in view display content. need understand how display data in nicely tabulated html format controller.
i know 1 way use javascript
$(#div_id).html(variable_embedded_html_coding);
all advise appreciated.
to have nicely looked table can use phpgrid.com
to send message php js having more 1 variable. can use example json or xml. encode array in php json format use json_encode(); in ajax should change datatype json.
so js side should this
var request = $.ajax({ url: "script.php", type: "post", data: {id : menuid}, //it'll in $_post['id'] datatype: "json" }).done(function(msg){ $("#your_div").html(msg.html); //msg.othervariable possible here });
from php(script.php)
$arr = array('html'=> "<p>asdasd</p>", othervariable=>"it works"); echo json_encode($arr);exit;
Comments
Post a Comment