weixin_33720078 2013-04-09 19:19 采纳率: 0%
浏览 80

将数据发送到服务器

I recently perform some ajax request on my website but I'm still beginner.

Here is a stupid question: How to send (POST) a data to the server without waiting any response ?

In all the example I found on internet, the ajax call is used to reload a part of the page. It work perfectly, but my idea here is just to send a data that could be store in DB for example without waiting any response.

I'm using Zend framework with MVC pattern. I tried something like:

$.ajax({
    type: "POST",
    url:'/controller/action',
    data: { myDataToPost: aData },

        success:function(response){
        },
        failure:function(){
         alert('Could not save your entry');
        }
});  

It works fine if I define an action in my controller but I can see in firebug an 404 error on controller/action page. For sure it doesn't exist because i don't want any response...

Many thanks for your help! Cedric.

  • 写回答

1条回答 默认 最新

  • 喵-见缝插针 2013-04-09 19:24
    关注

    "Here is a stupid question: How to send (POST) a data to the server without waiting any response ?"

    $.ajax({
         timeout: 1
    });
    

    Set the request timeout to 1 millisecond (zero doesn't work), thus giving the xmlHttpRequest 1 millisecond to complete (go to server, process request, return response, which is virtually impossible), otherwise mark it as timed out (failed).

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100