我试图与Yi一道编写一份言辞文件。 我觉得很难这样做。 我发现这个例子:,但我无法工作。
View:
echo CHtml::ajaxLink(
Generate Word ,
CController::createUrl( Calculator/generateWord ), array(
type => POST ,
), array( id => gen_word )
);
Controller:
$var = "hello";
$div = $this->renderPartial( graphs/print , array( var =>$var), true);
header("Pragma: no-cache"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false); // required for certain browsers
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment; filename="test.doc");
header("Content-Transfer-Encoding: binary");
ob_clean();
flush();
echo $div;
graphs/print:
<table>
<tr>
<td>This is just s test</td>
</tr>
<tr>
<td><?php echo $var; ?></td>
</tr>
</table>
当我点击“Generate Word”链接时,它就没有做任何事情。