无法通过Ajax发布数据

时间:2014-12-11 06:56:26

标签: php jquery ajax

php代码中的两个php变量..

$areaid = filter_var($_GET["aid"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
$areaname = filter_var($_GET["aname"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);

$(document).ready(function() {
    $("#submit_btn").click(function() { 

    var uareaname = <?php echo ($areaname) ?>;
    var uareaid   = <?php echo ($areaid) ?>;

    post_data = {'userArea':userareaname,'userAreaid':uareaid}; Not able to post this data

    $.post('review_me.php', post_data, function(response){

1 个答案:

答案 0 :(得分:0)

好的替换这些行:

var uareaname = <?php echo ($areaname) ?>;
var uareaid   = <?php echo ($areaid) ?>;

这些行:

var uareaname = '<?php echo ($areaname) ?>';
var uareaid   = '<?php echo ($areaid) ?>';

字符串值必须位于quotes。否则,它被视为变量。