Send data from bootstrap x-editable

梦想的初衷 提交于 2019-12-12 03:29:26

问题


How can I send data from bootstrap x-editable to the servlet? Currently my setup is like this:

$(document).ready( function() {
    $('a.accordion-toggle').editable({
        ajaxOptions: {
            dataType: 'json'
        }, 
        placement: 'right',
        name: 'toEdit',
        url: '../admin/module_edit.do',
        title: 'Edit'
    });
});

and my servlet is like this:

@RequestMapping( value = "/admin/module_edit", method = RequestMethod.POST )
public @ResponseBody
String editSubjectAndStrand( @RequestParam
String toEdit, HttpServletRequest request )
{
    System.out.println( toEdit );
    return "";
}

It didn't now print anything in my server side. What am I doing wrong?


回答1:


Finally I found the error. I should also define pk for it to send ajax request to the server. The documentation help me to solve this. In the documentation there is this part:

Main attributes you should define are:
type - type of input (text, textarea, select, etc)
url - url to server-side script to process submitted value (/post, post.php etc)
pk - primary key of record to be updated (ID in db)
id or name - name of field to be updated (column in db). Taken from id or data-name attribute
value - initial value. Usefull for select, where value is integer key of text to be shown. If empty - will be taken from element html contents



来源:https://stackoverflow.com/questions/19925984/send-data-from-bootstrap-x-editable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!