我想运行INSERT
由AJAX查询。该查询需要来自php会话的值,但js请求没有看到该值。这是怎么回事?我该怎么办 ?检查php会话由AJAX
一些下面的代码:
JS:
$('div#content').on("submit" , "form" , function (event){
event.preventDefault();
var href = "ajaxRequest.php" + $(this).attr("action");
var method = $(this).attr("method");
var values = $(this).serializeArray();
$.ajax({
url : href,
data : values,
type : method,
dataType : "html",
cache : false,
success : function (content){
alert(content);
}
});
});
PHP:在你PHP
页面顶部
public function addBoard($params = null)
{
$ID_user = $_SESSION[ 'user_id' ];
$board_model = $params[ 'board_model' ];
$query = "INSERT INTO `".prefix."boards` (
`ID_user` ,
`board_model`
)
VALUES (
'$ID_user', '$board_model');";
if($this->SQL->dbquery($query))
echo 'Added';
else
echo 'Failed';
}
add'session_start()' – 2013-04-08 11:15:29