How does PHP return variables + assemble HTML to Ajax
function html ($select, $name) {
Global $pagecon;
$a = ' 1 ';
$b = ' 2 ';
$result = ";
$result. = '
;
while ($row = $select->fetch ()) {
$result. = '
- ';
$result. = '
;
$result. = ' '. $pagecon. '
';
Return $result, $a, $b;
}
You need to return the $ A variable and the $b variable and an assembled $result HTML to Ajax. If you encapsulate Ajax without JSON
Share to: more
------Solution--------------------
Return "$result, $a, $b";
Success:function (JSON) {
A = Json.split (', ');
------Solution--------------------
function html ($select, $name) {
Global $pagecon;
$a = ' 1 ';
$b = ' 2 ';
$result = ";
$result. = '
;
while ($row = $select->fetch ()) {
$result. = '
- ';
$result. = '
;
$result. = ' '. $pagecon. '
';
return $result. '--$a. '--' $b;//Use--to connect back
}
function GetData (page) {
Alert (' OK ');
$.ajax ({
Type: ' Post ',
URL: ' action/test.php ',
Data: {' Pagenum ':p age-1},
Beforesend:function () {
$ ("#sss ul"). Append ("
Loading ...");
},
Success:function (JSON) {
var arr=json.split ('--');
$ ("#sss ul"). empty ();
result = arr[' 0 ']//gets the variable from PHP $result
Total = arr[' 0 ']//get variable $ A from PHP
PageSize =//Get the variable from PHP $b
$ ("Div#sss"). HTML (data);
},
Complete:function () {//RAW ingredient page strip
Getpagebar ();
},
Error:function () {
Alert ("Data load Failed");
}
});
}
Hope to help you!