如何用jquery调用cakephp动作?

I just want to call a cakephp action with jquery clicking on checkbox. I just want to refresh the current page by I want to use $.get because I want to send others variables to the action. I tried the following code :

HTML code :

<?php $chkOpt = array('pertinence' => $pert, 'onClick' => 'refresh_current_page()', 'id' => 'matchCoche'); ?>

<td class="check-column"><?= $form->checkbox($waiting['ArgusWaitingsMobilesPrice']['brand'] . ';' . $waiting['ArgusWaitingsMobilesPrice']['mobile'] . ';' . $waiting['search']['RefAvatar']['mobile_id'], $chkOpt) ?></td>

Javascript code :

<script type="text/javascript">
            function refresh_current_page() {
                $('#matchCoche').ready(function() {
                                $.get("<?php echo $this->here ?>");
                });
            }
        </script>

Does anyone can help me ?

Thanks a lot in advance for your help.

Better use click event. Dont mix it with HTML :)

$(document).ready(function(){
    $('#matchCoche').click(function(){
          $.get("http://"+ document.domain +"/yourController/yourAction/param1/param2/");
    });
});

Anyway, if you just want to call the page again with other parameters, why dont you use a normal HTML link for it?

As mentioned in the previous answer you're better off just using a regular link. You can send additional variable via named parameters:

<a href="/controller/action/id/variable1:value1/variable2:value2" />link</a>

The relevant documentation can be found at :

http://book.cakephp.org/view/1096/Using-Helpers for how to include non-default helpers http://book.cakephp.org/view/1589/script for using the 1.3.x Html helper to include scripts http://book.cakephp.org/view/349/Methods for using the 1.2.x Javascript helper

http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/Js.html

I always use Html helper to make the url, keeps me from trouble.

<?php 
$this->Js->buffer('
    $(document).ready(function(){
        $('#matchCoche').click(function(){
              $.get("' . $this->Html->url( array('controller' => 'your_controller', 'action' => 'your_action', 'param1', 'param2') ) . '");
        });
    });
'); 

?>

This assumes you have 'Js' helper loaded and have:

<?php echo $this->Js->writeBuffer(); ?>

in your layout before the closing body tag

I find it convenient to use Js->buffer. Js->writeBuffer will collect all the snippets from the buffer and take care of $(document).ready function.