doumie7914 2013-09-23 16:48
浏览 56

如何修改CakePHP Cart Plugin设置以使用AJAX按钮?

I am using the CakePHP Cart Plugin to add shop functionality to a website. I want to add items to the shopping cart using an AJAXified button. Submitting the form works fine. I am having trouble to correctly return just the shopped item as JSON data in method captureBuy() on line 210.

Which settings do I need to use and where/how do I set them? Any hint appreciated!

This is the request which is being sent:

Request URL:http://shop.site/carts_items/buy
Request Method:POST
Status Code:302 Found

Request Headers

Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:134
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:CAKEPHP=cd4611d0bf0100247928990a8efa72d0; rememberMe[User]=2....BmKdEs;
DNT:1
Host:shop.site
Origin:http://shop.site
Referer:http://shop.site/offer/1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1553.0 Safari/537.36 SUSE/30.0.1553.0
X-Requested-With:XMLHttpRequest

Form Data

_method:POST
data[CartsItem][foreign_key]:72
data[CartsItem][model]:Product
data[CartsItem][quantity]:1

Response Headers

Connection:keep-alive
Content-Type:text/html; charset=UTF-8
Date:Mon, 23 Sep 2013 20:32:28 GMT
Location:http://shop.site/offer/1
Server:nginx/1.0.15
Transfer-Encoding:chunked
  • 写回答

1条回答 默认 最新

  • dsa5211314 2013-09-23 19:29
    关注

    Define "not correctly". Paste your request and response from your network tab (in Chrome).

    You don't have to set the items, the CartManager is already setting them to the view and serializes them. At least it should.

    Make sure you have the RequestHandler component loaded as well.

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)