English 中文(简体)
采用表格 • 运送2份美国宇宙航空研究开发机构的请求的手稿?
原标题:Using Form Validation submitHandler to send 2 AJAX requests?
  • 时间:2012-04-20 14:32:53
  •  标签:
  • ajax
  • jquery

I ve got a pretty strong knowledge of php, html & csss but i ve onlystart to dive into javascript & jQuery.

i m面临的问题是,我在一页上有一个表格,我想先加以验证,然后才提出2项jax要求;第一,将数据列入我数据库的表格;第二,在另一个表格上提出询问并返还结果。

我用提交“Handler”的方法,用提交“Ajax”申请,在我网页上更新一片结果。 当我在此之后或之前加上第二批“jax”电话时,似乎会打断......

www.un.org/spanish/ecosoc 我的问题是。 是否应该像以下那样,在提名者中发出2个亚x,如果是的话,那么,这样做的正确途径是什么,甚至更好的方式?

$("#contactform").validate({
    rules: ...
    submitHandler: function() {
        // First to insert the contact details using input#firstname etc.
        var firstname = $("#firstname").value();
        var lastname = $("#lastname").value();
        var contactString =  firstname= + firstname +  &lastname=  + lastname;
        $.ajax({
            type: "POST",
            url: "insertcontact.php",
            data: quoteString,
            success: function(server_response){
                $( #yourquote ).html(server_response).show();
            }
        });            
        // Second use width & height submitted from previous page for processquote.php
        var width =  <?php echo json_encode($cleanpost[ width ]); ?>;
        var height = <?php echo json_encode($cleanpost[ height ]); ?>;
        var quoteString =  width= + width +  &height=  + height;
        $.ajax({
            type: "POST",
            url: "processquote.php",
            data: quoteString,
            success: function(server_response){
                $( #yourquote ).html(server_response).show();
            }
        });
    }
});

http://docs.jquery.com/Plugins/Validation”rel=“nofollow” jquery.validate.js accreditation plugin。 我的目标再次是,一旦有人用Ajax将其联络数据输入数据库,那么数据库就利用上页上提交的领域检索数字结果,以在网页上显示,而不进行复读。

你们能够给我的任何要点都会受到高度赞赏。

抢劫

<>光线> 学习 Java字和amp; 焦炭同时是这种好想法的 t头,一味混淆:this. Value = ; with $(this.val( );,如前2个变式声明所示,这是造成问题的原因! 感谢您的有益帮助,你将提供援助。

最佳回答

In your first .ajax() call, you are trying to pass it a value in the data: parameter that you have not created yet. I believe you are wanting to send it the contactString instead.

除非您的两次询问依次取决于对方,否则你就应当能够同步进行(基本上在同一时间)。 如果你想要在头一个月之后发出第二次非洲宇宙航空研究开发机构呼吁,那么你总是能够通过你的所有数据参数插入内容。 php,一旦插入,即执行程序。 具有你们已经传递的价值观。

最后,我想知道,你是怎样做的,但是,你们的日本宇宙航空研究开发机构都呼吁放弃在<条码>上的任何标准。 DOM要素并显示。 您不妨提出一个单独的要素,对您的两项请求作出答复。 或许#yourquoteinserted and #yourquoteprocessed?

www.un.org/chinese/ga/president http://api.jquery.com/jQuery.ajax/“rel=“nofollow noreferer”>。

http://www.ohchr.org。 Boolean

过失:真实

缺席时,所有请求均按规定顺序提出(即按违约情况确定)。 如果你需要同步的请求,就将这一选择定为不实。 交叉主要要求和数据表:“jsonp”要求不支持同步运行。 请注意,同步请求可暂时锁定浏览器<>/strong>,在请求有效期间放弃任何行动。

(斜体地雷)

However, I could be wrong about this but you might actually be able to call one asynchronous AJAX method from within the success function of another. If it starts looking too intermingled for you, you might want to extract the inner call into a function. Rough approximation of what it might look like:

$.ajax({url, data:contactString, 
    success: function(server_response) {
        extractedId = server_response; // you can return data many ways
        $.ajax({url2, data:quoteString+"&extra="+extractedId,...
        });
    }
});

如果你在第一次日本宇宙航空研究开发机构呼吁中通过制定<条码>:false发出同步呼吁,那么你只能将结果储存在外部(对美国宇宙航空研究开发机构呼吁)变数中(或者如果临时将结果储存在部分OM要素中)。 之后, j子将暂停执行,并在第一次被送回之前,打上了你第二次正义与和平运动的号召。

但现在,这完全是假设的,也是基于我对如何工作的理解。

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...