简体   繁体   中英

Using .submit() with CakePHP doesn't seem to be working

I'm .load() 'ing some code from a different file, inside this file is a form:

echo $this->Form->create('myForm', array('url' => array('controller' => 'myController', 'action' => 'myAction'), 'id' => 'myForm'));
//my input fields
echo $this->Form->end;

I wanted to be able to submit this form so I used:

$('#table').on('click', '#mySubmitButton', function() {
   $('#myForm').submit();
});

When I now click #mySubmitButton the form is rediecting to myAction but $this->request->data is empty. When I manually point my browser to the file that I'm loading the form works fine, it just wont post the data it gets .load() 'ed

Is this a common problem? And what can I do to get the form to submit properly?

Thanks

.load() code:

$(document).ready(function () { 
    $('#table1').load('link_to_file');
});

HTML output of the form:

<form id="myForm" accept-charset="utf-8" method="post" action="link_to_file"></form>

A form is not allowed to be a child element of a table, tbody or tr.

The other way around is acceptable (table is a child element of a form).

See the following question Form inside a table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM