问题
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