2013-10-30 48 views
0

你好朋友这是我的代码。jQuery用php变量发送post请求?

$.post("submit_investorform.php",{'flage':'firstOverviewsubmit','comname':comaname,'amoutwisr':amoutwisr,'user_id':<?php echo $value = isset($_GET['user_id']) ? $_GET['user_id'] : ""; ?>},function(result){ 
    if(result.trim() == 'Insert'){ 
     $(".noterror").html("Record Insert Successfully"); 
     $(".noterror").show(); 
     return false; 
    }else if(result.trim() == 'error'){ 
     $(".errordisplay").html("Something was Wrong Please Try Again"); 
     $(".errordisplay").show(); 
     return false; 
    }else if(result.trim() == "update"){ 
     $(".noterror").html("Record Updated Successfully"); 
     $(".noterror").show(); 
     return false; 
    } 

}); 

我想要做的user_id设置然后发送到发布请求,否则它发送空白。 但jQuery返回语法错误。

请大家帮忙。

+0

你正在得到什么确切的语法错误? 也是amoutwisr和comaname被定义的地方? – Mozak

回答

3

试试这个

'user_id': '<?php echo $value = isset($_GET['user_id']) ? $_GET['user_id'] : ""; ?>' 

你需要引号内包装你PHP代码,以避免语法错误,如果$_GET['user_id']没有设置。

+0

你好,谢谢你nauphal这是工作。 –