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
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);
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 the Network
panel. If not, it means the method is not executed. You can check if there is any error in the Console
panel. F12
調(diào)出開發(fā)者工具,在 Network
面板中查看是否有網(wǎng)絡請求。沒有的話說明方法沒有執(zhí)行,可以看看 Console
面板中有沒有報錯。
2.服務器端:如果瀏覽器請求發(fā)送成功,那么說明服務器收到了請求。可以用 die()
2. Server side: If the browser request is sent successfully, it means that the server has received the request. You can use die()
to breakpoint debugging.
In addition, it is recommended to capitalize the
$.ajax()
方法中的type
value.
First of all, it is impossible not to run without output. Please post the code. Or set some breakpoints to debug it yourself.