2
我的主頁通過一個變量的值:得到一個jQuery觸發事件
$(function(){
$('.controls').click(function(){
var id = $(this).attr('id'); //which in this case will be "pets"
$.ajax({
type:"POST",
data:"page="+id,
url:"controller.php",
success:function(result){
$('#content').html(result);
}
});
});
});
</script>
if (isset($_GET['myFave'])){
?>
<script>
$(function(){
var animal = "<?php echo $_GET['myFave'];?>";
$('#pets').trigger('click',[{'myFave':animal}]);
});
</script>
<?php
}
?>
Controller.php這樣
$page = $_POST['page']; //which will be "pets"
require_once($page.".php");
pets.php
<table align='center'>
////some data
/// how do i access trigger here?
如果用戶點擊在url上http://server.com?myFave=dog
on m y主頁我需要觸發點擊「寵物」。
所以主頁:
如何將我訪問的pets.php觸發傳遞的則params的價值?
而不是'$ _GET ['myFave']'你可以使用'$ page' – RST