passing an javascript object from cakephp view to controller

冷暖自知 提交于 2020-02-08 07:25:49

问题


I am developing a website using cakephp, and I'd like to pass a javascript object in view back to the controller. I know that using a form could be easier but I need to do this customized.

So here's the object ('annotation' and 'article_id' are real column names in the database, annotation and article_id are both variables containing data):

var postdata = {
    'annotation' : annotation,
    'article_id' : article_id
};

What method in the view should I use? Is it .post?

And how should I program the corresponding controller to correctly receive the object and extract data from it?


回答1:


You probably want to do an ajax request.



来源:https://stackoverflow.com/questions/7456940/passing-an-javascript-object-from-cakephp-view-to-controller

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