如果我理解正确,则需要使用JSON。这是一个样本。
在您的PHP中编写:
<?php// filename: myAjaxFile.php// some PHP $advert = array( 'ajax' => 'Hello world!', 'advert' => $row['adverts'], ); echo json_enpre($advert);?>
然后,如果您使用的是jQuery,则只需编写:
$.ajax({ url : 'myAjaxFile.php', type : 'POST', data: data, dataType : 'json', success : function (result) {alert(result['ajax']); // "Hello world!" alertedconsole.log(result['advert']) // The value of your php $row['adverts'] will be displayed }, error : function () {alert("error"); } })就这样。这是JSON-用于在服务器和用户之间发送变量,数组,对象等。此处有更多信息:http :
//www.json.org/。:)



