The requirement is like this, I have an ajax polling, requesting a php, php actively pushes messages to specific WeChat users, there is no output content,
I just want it to run, but the actual situation is that there is no output, it Not running.
I did a test, a code in php generates a file. Then a page runs ajax to request this php. No files are generated in the directory, but files are generated when running php directly, which means there is nothing wrong with my php. Below is the ajax code, take a look
<script>
function aj(){
$.ajax({
type: 'get',
dataType: 'html',
url: '/wechat/Wechatqyzj/ajaxPoll',
success:function(result){
//alert(result);
}
});
}
$(document).ready(function(){
setInterval('aj()',3000);
});
</script>
The header function can call the request, please try it. Or just make an ajax request
Post the php code, ajax can’t see anything
Access this api address directly. If there is normal data (for example: a json data is displayed on the page), the writing method of the timer here should be
setInterval(aj,3000);
Can the URL not be written in .php?
Tell me a few things that I think may be wrong
1.Success is not output, and I should also complete the error
2. If you are not sure about the request address, please write the absolute address
3. Paste the php code. It is very likely that there is an error in the backend
Use the developer mode of Google Chrome to see if an ajax request is initiated and what data the request returns, and then do further troubleshooting
Both ends can be debugged:
1. Browser side: Press
F12
to bring up the developer tools, and check whether there are network requests in theNetwork
panel. If not, it means the method is not executed. You can check if there is any error in theConsole
panel.F12
调出开发者工具,在Network
面板中查看是否有网络请求。没有的话说明方法没有执行,可以看看Console
面板中有没有报错。2.服务器端:如果浏览器请求发送成功,那么说明服务器收到了请求。可以用
die()
2. Server side: If the browser request is sent successfully, it means that the server has received the request. You can usedie()
to breakpoint debugging.First of all, it is impossible not to run without output. Please post the code. Or set some breakpoints to debug it yourself.