如何使用jquery通过ajax发送的电子邮件地址如何使用、电子邮件地址、jquery、ajax

2023-09-10 17:00:24 作者:天生暴脾气

var emailid='sample@email.com'
var data='email='+emailid;
    $.ajax({
               type: "POST",
               url: "sample.php",
               data: data,
               dataType: "text",
    });

我是通过AJAX发送EMAILID服务器。我是否需要连接code或去code电子邮件ID,同时发送。帮我同时通过AJAX发送电子邮件地址如何连接code和德$ C C是$。

i am sending emailid to server via ajax. whether i need to encode or decode email id while sending. Help me while sending email address via ajax how to encode and decode it.

推荐答案

不要将字符串传递给数据;使用一个对象,并让jQuery的处理编码:

Don't pass a string to data; use an object and let jQuery handle the encoding:

var emailid = 'sample@email.com',
    data = { email: emailid };
$.ajax({
           type: "POST",
           url: "sample.php",
           data: data,
           dataType: "text"
});

请注意,我已删除逗号从的dataType后使您的通话将工作在IE 6和; 7。

Note that I have removed the comma from after dataType so that your call will work in IE 6 & 7.