有一个网站包含某种数据。网站通过 Ajax 请求从您的页面发送此数据。所谓页面的持续加载。我可以使用 php 登录该网站。但我无法从 php 调用下载这些附加页面。
$(window).scroll(function () {
scroll = $(document).scrollTop() + window_height;
if (scroll > 1500){
button.fadeIn();
} else {
button.fadeOut();
}
if(!is_load || !brend) return false;
document_height = $(document).height();
if(document_height - scroll < 1000 && document_height != document_height_prev){
p = p + 1;
document_height_prev = document_height;
var data_send = {
mode: 'json',
brend: brend,
p: p
};
$.ajax({
url: '/catalog/getObjectsListBrend/',
data: data_send,
type: 'post',
dataType: 'html',
success: function(data) {
if(data.length < 100){
is_load = false;
}else{
$('div.tovars ul').append(data);
}
}
});
}
});
最佳答案
如果您想将数据发送到其他脚本,我建议使用 SoapClient 和 SoapServer 例如:
第一步创建一个SoapServer,您想在哪里获取和设置数据:
$srv = new SoapServer('Your_wsdl');
$srv->setClass("ServiceClass",$hdr);
$srv->handle();
class ServiceClass {
var $data;
public function setData($data){
$this->data = $data;
}
}
第二步:在要向 SoapServer 发送数据的位置创建 SoapClient:
$url = 'Your_wsdl';
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
现在你可以像这样传递到服务器数据:
$postData = array(
'mode' => 'json',
'brend' => 'zzz',
'page' => 1
);
$client->setData($postData);
//在这种情况下,您的数据设置在您创建 SoapServer 的位置:
关于javascript - 如何将ajax代码转换为php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21577617/