我正在为一个客户建立一个自助电子邮件运动应用程序。我希望客户下载他们想要的模板,数据将被发送到另一个页面。
我使用Jquery.Ajax来发布数据,但我需要它来选择客户端选择的html模板的内容:
获取模板
function getTemplate(id){
$.ajax({
type: 'get',
url: 'ay/templates/Postcard_Template.html,
data: 'EmailTemplate_id=' + id,
success: function(data) {
$('#shadow').fadeIn('slow');
$('#popupContact').fadeIn('slow');
$('#content').html(data);
}
});发布到新页面...
$.ajax({
type: 'Post',
url: 'wwww.Test.co.uk/test.html,
data: 'EmailTemplate_id=' + id,
success: function(data) {
$('#shadow').fadeIn('slow');
$('#popupContact').fadeIn('slow');
$('#content').html(data);
});然后我会将这个绑定到一个表单,如果这看起来是正确的,有什么建议吗?
谢谢,汤姆。
发布于 2012-11-01 19:43:11
我能看到的错误是gettemplate中缺少了一个单引号:
function getTemplate(id){
$.ajax({
type: 'get',
url: 'ay/templates/Postcard_Template.html',
data: 'EmailTemplate_id=' + id,
success: function(data) {
$('#shadow').fadeIn('slow');
$('#popupContact').fadeIn('slow');
$('#content').html(data);
}
});和post模板中的单引号+方括号:
$.ajax({
type: 'Post',
url: 'wwww.Test.co.uk/test.html',
data: 'EmailTemplate_id=' + id,
success: function(data) {
$('#shadow').fadeIn('slow');
$('#popupContact').fadeIn('slow');
$('#content').html(data);
}
});我的建议是,如果你要把它绑定到一个表单上,你应该序列化这个表单,并把它传递给data参数。简短的示例:
<form id="menu">
<select name="daymenu" size="3" multiple>
<option value="1">maple</option>
<option value="2">hickory</option>
<option value="3">birch</option>
</select>
</form>然后调整您的ajax数据:
data: $("#menu").serialize(),祝你好运汤姆:)
https://stackoverflow.com/questions/13175891
复制相似问题