如何使用get方法jQuery中我提交表单表单、如何使用、方法、get

2023-09-10 19:17:28 作者:茗灬人

我知道使用方法= GET

I am aware of sending form values using the method=get

<FORM METHOD=get ACTION="test.html">

我有一个文本框捕捉电子邮件。当我使用GET方法提交表单的@转换为40%。 我在某处读到过的Jquery可以在由串行发送数据。怎样才能做到呢? 谢谢

I have a textbox which captures email. When i submit form using the GET method the @ is converted to %40. I had read somewhere that Jquery could send the data across by serializing. How can it be done? Thanks

推荐答案

如果你想使用jQuery 连载(提交表单)和GET方法,你可以做这样的事情:

If you want to submit a form using jQuery serialize() and GET method, you can do something like this:

如果你使用PHP的:

表格:

<form action='test.php' method='GET' class='ajaxform'>
   <input type='text' name='email'>
</form>

jQuery的:

jQuery(document).ready(function(){

    jQuery('.ajaxform').submit( function() {

        $.ajax({
            url     : $(this).attr('action'),
            type    : $(this).attr('method'),
            data    : $(this).serialize(),
            success : function( response ) {
                        alert( response );
                      }
        });

        return false;
    });

});

在的test.php 您可以收到电子邮件这样的:

In test.php you can get email like this:

$ _ GET [电子邮件]

详细资料:

http://api.jquery.com/jQuery.ajax/