weixin_33728708 2015-02-16 12:09 采纳率: 0%
浏览 24

调用和结束ajax函数

When I call ajax function such

 $(save_Data()).ajaxStop(function()
     {
        new_Form(code);
     }


 function save_Data()
   {
      // here send data to php and save it
   }

Now, I call another ajax function such

  $(get_Data()).ajaxStop(function()
       { 
             // doing some thing
       }


  function get_Data()
   {
      $.ajax
        ({
            type: 'POST',
            url: 'insert_Stock.php',
            data: { insert_Data : inserted_Data },
            dataType: 'json',
            success:function(data)
                {
                   // doing some thing such call another function to control on form
                }
        });
   }

When I call save_Data function already new_Form function execute, after that when I call get_Data function the new_Form function execute automatically. Why new_Form function execute?

  • 写回答

1条回答 默认 最新

  • weixin_33716154 2015-02-16 12:40
    关注

    If I understood you this is what you want.

    function doSomething(){
      //your code here if success
    }
    
    function doSomethingElse(){
      //your code here if error
    }
    
    function finallyDoSomethingElse(){
      //your code here no matter what is the result of post
    }
    
    $.ajax({
        type: 'POST',
        url: 'insert_Stock.php',
        data: { insert_Data : inserted_Data },
        dataType: 'json',
        success: doSomething,
        error: doSomethingElse,
        complete: finallyDoSomethingElse
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊