我的aspx页面中有一个空div,我在该div中生成动态内容。
<div id="book"> </div>
加载我的div内容后
<div id="book">
<div class=’a’ style=”left: 0px ; width:469px;"> … </div>
<div class=’b’ style=”left: 0px ; width:469px;"> … </div>
<div class=’c’ style=”left: 0px ; width:469px;"> … </div>
</div>
我想在一个txt文件中使用html代码。基本上我的txt文件包含数据:
<div class=’a’ style=”left: 0px ; width:469px;"> … </div>
<div class=’b’ style=”left: 0px ; width:469px;"> … </div>
<div class=’c’ style=”left: 0px ; width:469px;"> … </div>
jQuery中是否有这样的功能?请帮帮我。
答案 0 :(得分:0)
答案 1 :(得分:0)
$.ajax({
url : 'path/to/file.txt',
dataType : 'html',
success : function(html) {
$('#book').html(html);
}
});
答案 2 :(得分:0)
// get contents of div, set to variable txt
var txt = $('#book').html();
// send contents of txt to asp handler,
// ie. some function that takes an input and saves it on your server
var request = $.ajax({
type: 'POST',
dataType : 'html',
url: "handler.asp",
data: txt
});
request.done(function(data){
// success
console.log(data);
});
request.fail(function(jqXHR, textStatus,responseText){
// failed
console.log(jqXHR, textStatus,responseText)
});