我在 CakePHP 项目中完成了一些 jQuery 函数,但最后我决定尝试Ajax Helper。不幸的是,我不知道如何将参数(表单字段值)传递给 AJAX 函数。我做了以下事情:
$obtainProduct = $ajax->remoteFunction(
array(
'url' => array( 'controller' => 'products', 'action' => 'obtain', '{$OrderProductId->id}'),
'update' => 'post' )
);
...
echo $form->input('product_id', array('empty' => true, 'onchange' => "$obtainProduct"));
它调用函数但没有检索我需要的参数。
我从 API 链接文档 -api.cakephp.org/class/ajax-helper 得到了这个想法,我想从选择框中获取 ID,获取它的值并在后端进行一些查找。
那么如何通过助手获得 ('#OrderProductId option:selected').val 或类似的东西?