如何将 html 元素值提交到其在 Kohana 中的相应控制器


How can I submit html element value to its corresponding controller in Kohana

我在项目中使用的是kohana 2x版本,我在视图中选择了框,如下所示

<select id='type'>
<option value='type1'>Type1</option>
<option value='type2'>Type2</option>
</select>

默认情况下,加载页面时将选择Type1。但是当用户选择 type2 时,它将该值提交给其控制器。这里的问题是我在这里没有使用表单,即使我需要在不使用表单和提交按钮的情况下将所选值提交到控制器。就在用户选择时,Type2从选择框中,我只需要将其值提交到其控制器即可。我不太擅长Jquery和Ajax,即使我可以管理这个问题的一些答案。

提前致谢

问候马赫什·

$("#type").change(function() {
    var input = $(this).val();
    // If you want to reload the page, use javascript to redirect
    // Or you can use ajax to send the selection dynamicly
});

您可以找到有关使用 ajax 发送的信息:jQuery Ajax