【问题标题】:How to change submit value of form after used by AjaxFormAjaxForm使用后如何更改表单的提交值
【发布时间】:2013-03-02 08:56:44
【问题描述】:

我正在使用 AjaxForm 扩展来提交带有 ajax 的表单,如下所示

var options = 
        {
            url:'<?php echo site_url('user/ajaximage')?>',
            dataType: 'json',
            success:   function(data)
            {
                if(data.messagecode==1)
                {
                    $(".wrap label").hide();
                    $("#preview").html("<img src='"+data.content+"'class='preview'>");
                    $("#errormessagepic").hide();
                }
                else if(data.messagecode==0)
                {
                    $("#errormessagepic").html(data.content);
                    $("#preview").html('<img width="100" height="100" src="<?php echo base_url();?>/images/avatar_generic.png" />');        
                }
                //$('#SignupForm').resetForm();
                //$("#SignupForm").attr('action','<?php echo site_url('user/individualprofile')?>');
            } ,
        }; 
        $("#SignupForm").ajaxForm(options);
        $("#SignupForm").submit();

但是在这个 ajax 提交之后,我想将表单重新发送到 '' 以外的另一个 URL,但它不起作用。任何帮助

【问题讨论】:

    标签: ajax jquery ajaxform


    【解决方案1】:

    好的,所以您想使用 ajax 将表单发布到两个不同的 url。我不知道你的扩展,但我可以告诉你如何做到这一点。

    1- 创建一个函数并在用户点击提交时运行该函数

    2- 创建函数体,该函数会将数据提交到两个url

        function post_form(){
    
        // save the values in text boxes in variable
    
        var val1=$("#text1").val();
        var val2=$("#text2").val();
    
        var data={name:val1,age:val2};
    
        var url1="savedata.php";
        var url2="updatedata.php";
    
        $.post(url1,data, function(response){ 
    
        alert(response);
    
        // so when the form is submited to ur1 this callback function runs and here you can submit it to another url
    
        $.post(url1,data,function(response){alert(response)});
    
        });
    
        }
    
    </script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 2015-11-15
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      • 1970-01-01
      相关资源
      最近更新 更多