0

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>

1 つの 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 にそのような機能はありますか? 私を助けてください。

4

3 に答える 3

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)
});
于 2013-04-17T07:19:51.733 に答える
0
$.ajax({
    url : 'path/to/file.txt',
    dataType : 'html',
    success : function(html) {
        $('#book').html(html);
    }
});
于 2013-04-17T06:54:45.813 に答える
0

AJAXをチェック

特定の要素にコンテンツを動的にロードするように特別に設計されています

このリンクはJQueryを参照しています。プレーンなJavaScriptで実行できますが、コードはJQueryで必要な3行に展開されます

于 2013-04-17T06:54:15.813 に答える