これを行うにはどうしますか?私のajaxはjavascript変数を設定しますが、document.writeを使用して表示しようとすると、html要素をカバーします。私はjavascript変数を使用することができ、html要素を隠すことができないようにこれを行うことができますか?前もって感謝します。javascript変数を設定するAjaxレスポンスがhtml要素をカバーしています
<html>
<head>
<title>Log In</title>
<!-- script tag for ajax jquery -->
<link href='style.css' type="text/css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
//Get Data ajax function
$.post(
'getData.php',
{
},
function(response)
{
$('#name').html($('#1' , response).html());
$('#sname').html($('#2' , response).html());
var x = $('#1' , response).html();
document.write(x);
})
return false;
})
</script>
</head>
<body>
<div id="name"></div>
<div id="sname"></div>
this is text that get covered up, as well as any other html elements
</body>
</html>
最初はなぜdocument.write()を使用していますか、そして2番目の理由でそれを
に書き込もうとしていますか? jQueryが 'ready'メソッドを実行すると、そのページはすでにロードされており、HTMLストリームは閉じられています。 – Robusto