【发布时间】:2014-01-28 00:00:13
【问题描述】:
我有一个带有 ie 表单的 jsp 页面。
<form name="contact" action="">
<fieldset>
<div id="res"></div>
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value="" class="text-input" />
<label class="error" for="name" id="name_error">This field is required.</label>
<label for="email" id="email_label">Return Email</label>
<input type="text" name="email" id="email" size="30" value="" class="text-input" />
<label class="error" for="email" id="email_error">This field is required.</label>
<label for="phone" id="phone_label">Return Phone</label>
<input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
<label class="error" for="phone" id="phone_error">This field is required.</label>
<br />
<input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
</fieldset>
</form>
<div id="res"></div>
还有一个用于按钮的 ajax
$.ajax({
type: "POST",
url: "processServlet",
data: dataString,
success: function(data) {
$('#res').wrap(data);
}
});
return false;
});
在 servlet 中我有带有 html 标签的字符串
String te="<div class=\"input-control text\" \n" +
" data-role=\"datepicker\" \n" +
" data-week-start=\"1\"\n" +
" data-format='m/d/yyyy'\n" +
" data-effect='slide'>\n" +
" <input type=\"text\" placeholder=\"Date purchased\"
name=\"DATEPURCHASED\" id=\"DATEPURCHASED\">\n" +
" <button class=\"btn-date\" disabled></button>\n" +
"";
out.println(te);
servlet 将日期选择器返回到 jsp 页面。当日期选择器显示在 jsp 页面中时,日期选择器似乎不起作用?我做错了什么?我需要将整个 html 文件返回到页面吗?看起来他们没有共享主 jsp 页面的 css 和 js。
【问题讨论】:
-
任何使用 $('#res').wrap(data); 的理由而不是 $('#res').html(data)?
-
@developerwjk 我已经在网上搜索了如何在 div 中插入元素,wrap 和 html 有什么区别?