URL http://rid3201.org/site/club_members2.php?id=MTk3Ng==から「コンテナ」divを抽出したい 。そのために次のコードを使用します(MVC4で)
私のコントローラー
public string DownloadUrlData()
{
using (System.Net.WebClient wc = new System.Net.WebClient())
{
wc.Encoding = System.Text.Encoding.UTF8;
string htmlCode = wc.DownloadString("http://rid3201.org/site/club_members2.php?id=MTk3Ng==");
return htmlCode;
}
}
私のhtmlページとjqueryは
@section head{
<script type="text/javascript">
$(document).ready(function () {
$.ajax(
{
url: '/Member/DownloadUrlData',
type: "POST",
dataType: "html",
async: true,
cache: false,
beforeSend: function (request) {
},
success: function (data) {
var theHtml = $(data).find('#container>table:first').html();
// var $theTable = $(theHtml);
$("#rData").append(theHtml);
// Use this HTML or jQuery object to serve your objective
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
//alert(textStatus + ", " + errorThrown + ", " + xmlHttpRequest);
},
complete: function (xmlHttpRequest, textStatus) {
}
});
});
</script>
}
<div id="rData">
</div>
そのテーブル(コンテナdiv内)をdiv rDataに追加したい。HTMLコード全体(データ内)を取得できます。ただし、rData div を抽出して読み込むことはできません。その部分は機能していません。
問題は、jqueryがデータにアクセスできないことです。どうすればこれを削除できますか