一个ajax在a页面中获取b页面中某域值的有关问题
一个ajax在a页面中获取b页面中某域值的问题
一般都是a页面向b页面传值 但我现在需要在a页面中获取b页面中特定区域的值 该怎么做呢?谢谢!
a.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type:"post",
url:'b.html',
data:'',
cache:false,
success:function(e){alert(e)}
})
})
</script>
<title>无标题文档</title>
</head>
<body>
</body>
</html>
b.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var v=$("#test").text();
})
</script>
<title>无标题文档</title>
</head>
<body>
<div id="test">xxx</div>
</body>
</html>
------解决方案--------------------
你如何保证客户把两个页面都打开?
------解决方案--------------------
纯粹地解决问题,不考虑其他
一般都是a页面向b页面传值 但我现在需要在a页面中获取b页面中特定区域的值 该怎么做呢?谢谢!
a.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type:"post",
url:'b.html',
data:'',
cache:false,
success:function(e){alert(e)}
})
})
</script>
<title>无标题文档</title>
</head>
<body>
</body>
</html>
b.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var v=$("#test").text();
})
</script>
<title>无标题文档</title>
</head>
<body>
<div id="test">xxx</div>
</body>
</html>
------解决方案--------------------
你如何保证客户把两个页面都打开?
------解决方案--------------------
纯粹地解决问题,不考虑其他
- JScript code
$.ajax({ type: "post", url: 'b.html', dataType: 'html', cache: false, success: function (result) { var $result = $('<div></div>').hide(); $result.html(result); alert($result.text()); }, error: function () { alert('error'); } });
------解决方案--------------------
约定dataType为'html',写到最简,success里只有一句
- JScript code
alert($('<div></div>').html(result).text());
------解决方案--------------------
显示b页面 里面table 的内容。
$('#a页面的显示区域').load('b页面地址 table');
------解决方案--------------------