我需要在没有页面刷新的情况下更改div中的html,而php运行foreach语句,我认为这可以通过jquery实现,但我不确定我是否正确地实现了这一点。这是我目前的代码。
$filename = "entries.csv";
$topic = $_GET['q'];
$file = new SplFileObject($filename, 'w');
$sentences = explode(".", getResultsPage(getBingLink($topic)));
$file->fputcsv(array("Topic", "Sentence", "Word", "Tag"));
foreach($sentences as $sentence){
?>
<script>
$("#view").html('<?php echo $sentence; ?>');
</script>
<?php
if(preg_match("/^[A-Za-z0-9òàùèìé\s\?\!\,\-]*$/",$sentence)){
$words = $pos->tag(explode(" ", $sentence));
foreach($words as $word){
$file->fputcsv(array($topic, $sentence, $word[0], $word[1]));
}
}
}
因为它只在加载页面时打印脚本。非常感谢任何有用的提示或建议。感谢名单。