javascript - ajax how to request php, php not running
仅有的幸福
仅有的幸福 2017-05-27 17:41:54
0
8
747

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>
仅有的幸福
仅有的幸福

reply all(8)
曾经蜡笔没有小新

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 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 调出开发者工具,在 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 use die() to breakpoint debugging.

In addition, it is recommended to capitalize the $.ajax() 方法中的 type value.

Peter_Zhu

First of all, it is impossible not to run without output. Please post the code. Or set some breakpoints to debug it yourself.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template