查找链接并通过电子邮件发送给我

问题描述:

我该如何制作一个简单的html表单(只有名称&电子邮件),当提交了一些jquery在页面上找到特定链接并将它与来自形式到web服务器,其中一个脚本,然后从形式与链接 链接一起发送邮件到的电子邮件地址总是先从同样的事情,看起来像:查找链接并通过电子邮件发送给我

http://www.exemple.com/abcd/1u3odjeo 
http://www.exemple.com/abcd/340fkdl4 

这是我得到了什么现在为表格:

<!DOCTYPE html> 
<html> 
<head> 
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script> 
$(document).ready(function(){ 

$('#submit').click(function(){ 

$.post("send.php", $("#mycontactform").serialize(), function(response) { 
$('#success').html(response); 
//$('#success').hide('slow'); 
}); 
return false; 


}); 

}); 
</script> 
</head> 
<body> 

<form action="" method="post" id="mycontactform" > 
<label for="name">Name:</label><br /> 
<input type="text" name="name" id="name" /><br /> 
<label for="email">Email:</label><br /> 
<input type="text" name="email" id="email" /><br /> 
<input type="button" value="send" id="submit" /><div id="success" style="color:red;"></div> 
</form> 
</body> 
</html> 

我错过了链接抓取以及如何将其添加到发送电子邮件的脚本中。

感谢所有帮助

+0

这些链接将位于您的页面上? – tymeJV

+0

这些链接是静态的吗?似乎将隐藏表单字段中的链接URL包含起来会更容易。 – David

获取网页中的链接,其序列和发送之前插入的形式隐藏输入。您也可以将链接值集中到序列化的字符串上:

$(document).ready(function() { 
    $('#mycontactform').on('submit', function(e) { 
     e.preventDefault(); 
     var link = $('a[href*="http://www.exemple.com/abcd/"]').attr('href'); 

     $('<input />', {type: 'hidden', name : 'link', value: link}); 

     $.post("send.php", $("#mycontactform").serialize(), function (response) { 
      $('#success').html(response); 
     }); 
    }); 
});