我有一个表单,让用户输入他们的搜索词,然后通过 jquery ajax post 传递到另一个页面。在流程页面上,我有以下代码:
<?php $searchText = $_REQUEST["searchText"]; ?>
<script type="text/javascript">
$('.facebookfeed').append('<p>Loading your results</p>');
var url = 'https://graph.facebook.com/search?q=';
var url = url+searchText.value;
var url = url+'&type=post&limit=60&callback=?';
$.getJSON(url,function(json){
console.log(data);
var html = "<ul>";
if (json.data == ''){html += '<li><h2>Sorry, no results were found. Try with another search term.</h2>'; }
$.each(json.data,function(i,fb){
if (!fb.message == ''){
html += '<li><div class="box">'
html += '<a href="http://www.facebook.com/'+ fb.from.id +'" target="_blank"><img src="https://graph.facebook.com/' + fb.from.id + '/picture" /></a>';
html += '<p><span class="name"><a href="http://www.facebook.com/'+ fb.from.id +'" target="_blank">' + fb.from.name + '</a></span> <br />';
html += fb.message;
html += '</p></div></li>';
}
});
html += "</ul>";
$('.facebookfeed').animate({opacity:0}, 500, function(){
$('.facebookfeed').html(html);
});
$('.facebookfeed').animate({opacity:1}, 500);
});
</script>
此代码在 Chrome 和 Safari 上正常工作,但在 Firefox 中我收到以下错误:
Error: searchText is not defined
我似乎无法弄清楚这里的问题是什么?任何帮助是极大的赞赏。