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