使用jquery的.post实现无刷新传值
但是php貌似post不到传来的值
/********************js*********************/
function setClickable() {
$('#editInPlace').click(function() {
var content=$(this).html();
var textarea = ' <div> <textarea rows="5" cols="5">'+content+' </textarea>';
var button = ' <div> <input type="button" value="OK" class="saveButton"> </div> </div>';
var revert = $(this).html();
$(this).after(textarea+button).remove();
$('.saveButton').click(function(){saveChanges(this, false);});
})
};
function saveChanges(obj, cancel) {
if(!cancel) {
var t = $(obj).parent().siblings(0).val();
$.post("test2.php",{content:'t'},function(a){alert:a;});
}
else {
var t = cancel;
}
if((t=='')||(/ <\/xmp>/gi.test(t)))
t='点我,写心情';
$(obj).parent().parent().after(' <div id="editInPlace"> <xmp>'+t+' </xmp> </div>').remove();
setClickable();
}
/***************html****************/
<body>
<div id="editInPlace">........ </div>
</body>
/*************text2.php****************/
<?php
echo $_POST['content'];
?>