我有一个PHP脚本,它有一个选择框,它允许用户过滤一些数据。而且我用选择框上的更改事件触发jquery的加载函数加载一个div的另一个页面,它将显示过滤的数据。现在的问题是我有一个JavaScript函数,这是从该页面调用一些检查在PHP中,这导致该函数根本不会被调用。是在这种情况下的任何解决方法?我尝试使用$ .get(),但我不确定它是否会允许我只加载页面的一部分。加载()函数将不允许页面上的脚本执行
这是load()函数的调用
$('document').ready(function() {
$('#topic-filter-select').on('change' , function(e) {
$.ajax({
type: 'GET',
url: templateUrl+"/ajax/custom_ajax_functions.php",
data : {
functionName : 'load_topic_filter',
topic_id : e.target.value
},
success: function(result) {
for(var i=0;i<result.length;i++)
result[i] = parseInt(result[i]);
result = JSON.stringify(result);
$('#activity-container').empty();
$('#activity-container').load("/topic-filter-template?result="+result+" #topic-page");
},
error: function(error) {
$('#post-0').empty();
$('#post-0').append("<div id='filtered-activities'><h4>Something went wrong , please try again.</h4></div>");
}
});
});
});
,而PHP的支票给调用javascript函数是
<?php $result = has_user_voted($poll_id , $current_user_id);?>
<?php if($result[0] == true) :?>
<?php echo '<script type="text/javascript">animatePollEffect('.json_encode($result).','.$poll->ID.')</script>';?>
<?php endif; ?>
[阅读提示](http://stackoverflow.com/help/how-to-ask) –