jquery.ajax可以從屬性Name中發佈一個值嗎?如果可以,我想將圖像標題apple
發送到b.php,然後將數據This is an apple
從b.php返回到div#result
,謝謝。jquery.ajax是否可以從屬性名稱發佈值?
a.php只會
<html>
<head>
</head>
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function() {
var params = "value=" + $('#send').attr(title);
$.ajax({
url:'b.php',
type:'post',
dataType:'html',
data:params,
success:data
});
function data (html) {
$("#result").html(html);
}
});
</script>
<body>
<div id="result"></div>
<img id="send" src="apple.jpg" title="apple" />
</body>
</html>
b.php
<?php
echo 'This is an '.$_REQUEST['value'].'.';
?>
加引號「標題」在您的來電.attr() – tkm256 2011-03-04 22:45:14
沒錯,我的粗心,忘了報價...... – 2011-03-04 22:59:44