使用$ .post()中的数据刷新页面

I am trying to send data to a index page when a link on that page is clicked. the index.php page looks like this:

include "../app/bootstrap.php";
include ("../src/controllers/DisplayContentsController.php");

$data = new DisplayContentsController();
$link = (isset($_POST['link']) ? $_POST['link'] : null);

if ($link != null)
{
    $data->show($twig, $starting_file_path . '/' . $link);
    $starting_file_path = $starting_file_path . '/' . $link;
}
else
{
    $data->show($twig, $starting_file_path);
}

and on the Twig template that is loaded I have this:

<script>
    jQuery('.show_content').click(function(e)
    {
        e.preventDefault();

        var href = jQuery(this).attr('href');
        jQuery.post(window.location, { link: href });
    });
</script>

I want to reload the page with the new link that way it loads the correct directory. But when I do the jQuery.post() the content that is displayed does not change. Can someone help my find out what is going wrong and how I can accomplish this?

查看全部
douzhulan1815
douzhulan1815
2014/03/31 18:04
  • php
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复