Ajax 响应滞后
我正在向 Codeigniter 中的控制器/操作发送 ajax 请求,它会执行一些操作并发送响应。 我得到的响应是准确的,但发送响应所需的时间是 4-5 秒,这是一个巨大的时间。
我能够调试并查明造成这种延迟的原因。在该方法的最后,我将发送一封邮件。我在这里使用 mail() 函数。我什至通过编写 @mail() 来抑制错误,因此在本地主机上它不会给出任何错误并且在实时服务器上执行良好。
但即使没有错误,本地环境和实时服务器上也存在延迟。我不确定问题是什么。 现在,一旦我删除/注释掉 mail() 函数,响应就会立即发生并且快如闪电。
请让我知道可能出现的问题以及可能的解决方案。
提前致谢。
I am sending an ajax request to a controller/action in Codeigniter and it does some manipulation and sends a response.
The response that I get is accurate but the time taken for it to send the response is 4-5 seconds which is huge.
I was able to debug and pin point the cause of this lag. At the end of the method I am sending a mail. I am using mail() function here. I am even suppressing the error by writing @mail(), so on localhost it is not giving any error and executes well on the live server.
But even though there is no error, there is lag in both the environment i.e. locally and on Live server. I am not sure what the problem is.
Now as soon as I remove/comment out the mail() function, the response is instantaneous and lightning quick.
Please let me know what might be the issue what might be the possible solution.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PHP mail() 的功能非常有限。尝试使用代码点火器电子邮件类: http://codeigniter.com/user_guide/libraries/email.html
PHP mail() is very limited. Try using the code igniter Email class: http://codeigniter.com/user_guide/libraries/email.html