我試圖通過ajax更新學生的配置文件腳本運行良好我獲得了所有在dataString中傳遞的值,但它沒有更新字段的值,當savebasic.php通過ajax調用。在通過ajax發佈值時更新表字段的錯誤
的Jscript:
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".savestudent").click(function() {
var _firstname=$("#firstname").html();
var _lastname=$("#lastname").html();
var _gender=$("#gender").html();
var _location=$("#location").html();
var _aboutme=$("#about").html();
var _dob=$("#dob").html();
var dataString= 'fname='+ _firstname + '&lname='+ _lastname + '&gender='+ _gender + '&location='+ _location + '&about='+ _aboutme + '&dob='+ _dob ;
alert(dataString);
$.ajax
({
type: "POST",
url: "savebasic.php",
data: dataString,
cache: false,
success: function(html)
{
alert('success');
},
error: function(html)
{
}
});
});
});
</script>
savebasic.php:
<?php
include_once('controller/profile.controller.php');
$profileObject=new ProfileController();
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$gender='M';
$loc=$_POST['location'];
$about=$_POST['about'];
$birth=$_POST['dob'];
$upt=$profileObject->updateUserprofile('59',$fname,$lname,$birth,$gender,$loc,$about);
?>
,如果我直接傳遞savebasic.php它的工作原理值。但是通過ajax時它什麼都不做。
不,他們在標籤和即時獲得所有的價值,雖然 – 2013-02-27 10:38:26
好吧,這很好 – 2013-02-27 10:42:24