如何將表單值和用戶ID傳遞給ajax?如何通過AJAX傳遞表單值和個人值?
的javascript:
jQuery("#DoneBtn").click(function(){
var data = $("#insertsubs_form").serialize();
<?php
$db = JFactory::getDBO();
$user = JFactory::getUser();
?>
var userid = <?php echo $user->id; ?>
$.ajax({
data: {
data:data,
userid : userid
},
type: "post",
url: "../insert_subs.php",
success: function(data){
alert(data);
}
});
});
在insert_subs.php:
$userid = $_GET['userid'];
****衷心感激阿南德帕特爾,蒂娜。兩者都是我想要的相同答案! :D同樣感謝epascarello!我沒有嘗試這個,但我認爲也是如此。 :)