2013-10-30 183 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這是工作。 –