jQuery .post返回CakePHP中的整个页面

I have a problem when passing the data to php using jquery .post.

Html

<div class="wrp">
    <h1>Product <? echo $pd['Product']['name'] ?></h1>

    <input id="qty" type="text" name="qty">
    <input id="add" type="button" value="Add to cart">

</div>

<script type="text/javascript">
$(document).ready(
function()
{
$('#add').click(function()
{
        $.post(
            '/shop/addtocart',
            {
                qty : ('#qty').val();
            },
            function(data){
                alert(data);
            }
        )
}
);
}
);
</script>

and the /shop/addtocart function

public function addtocart(){

    if($this->request->is('ajax')){

    $qty = $_POST['id'];
    echo $qty;

    }

}

and when I click it alerts me the desired value but after the value it echoes the whole html code.

Please help!

Solved!

just added a exit; after echo

public function addtocart(){

    if($this->request->is('ajax')){

    $qty = $_POST['id'];
    echo $qty;
    exit;

    }
}

Try to change:

qty : ('#qty').val();

to:

qty : $('#qty').val();
public function addtocart(){
   $this->layout = 'ajax';
   if($this->request->is('ajax')){
        $qty = $_POST['id'];
        echo $qty;
    }
}