GETフォームの結果ページをdivにターゲットにする方法を探しています。これまでのところ、ほとんどのソリューションでは代わりに Iframe を使用するように指示されていましたが、私の目的は結果ページに何らかの変更を加えることであり、Iframe を使用するとクロス ドメイン スクリプティング ルールがアクティブになり、ページ コンテンツを取得できなくなります。
結果ページは通常、未加工の XML です。
<html>
<head>
<link rel="stylesheet" href="css/smoothness/jquery-ui-1.9.2.custom.css" >
<script src="js/jquery-1.8.3.js"></script>
<script src="js/jquery-ui-1.9.2.custom.js"></script>
<script src="js/jquery.xslt.js"></script>
<script type="text/javascript">
$(function() {
var xmlContent = $("#CFrame").contents().find("*").text();
$('#SResult').xslt({xml:xmlContent, xslUrl:'stylesheet/styleSheet.xsl'});
});
// prepare the form when the DOM is ready
function submitForm() {
// bind form using ajaxForm
$('#searchForm').ajaxForm({
// dataType identifies the expected content type of the server response
dataType: 'xml',
// success identifies the function to invoke when the server response
// has been received
success: processXml
});
return false;
}
function processXml(responseXML) {
// 'responseXML' is the XML document returned by the server; we use
// jQuery to extract the content of the message node from the XML doc
var message = $(responseXML).text();
$("#SResult").text(message);
}
</head>
<body>
<form id="searchForm" method="GET" action="http://111.11.111.11:1111/search" onSubmit="submitForm()">
<!--.... Some input go here-->
<input type="submit" value="Search" />
<div id="SResult">
</div>
<iframe id="CFrame" name="ContentFrame" frameborder="1" height="1000px" width="1000px" scrolling="no"></iframe>
</body>
<script>
loadUI();
</script>
</html>
ありがとう、