unk*_*own 1 javascript ajax jquery
当我使用脚本从使用ajax获取特定URL的内容时,我的HTML内容不会显示,即我的表元素没有显示:我从特定URL获取数据,我在警告框中显示它,并且还使用document.write在页面上写入来自我调用的URL的数据:
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type:"POST",
url:"http://your url",
success: onSuccess,
error:onError
});
});
function onSuccess(data){
var servertext=data;
document.write(servertext);
alert(servertext);
}
function onError(data){
alert(data+'error');
}
</script>
</head>
<body>
<p> hello</p>
<table height="150px" weight="150px" border="1px">
<tr>
<td><img src="green.png" height="100px" width="100px" /></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
enter code here
document.write页面加载完成后不应使用.如果你调用它,它将隐式调用document.open,这会使页面空白并创建一个新文档.
| 归档时间: |
|
| 查看次数: |
174 次 |
| 最近记录: |