I am struggling with an ajax request. The client selects a quantity of an item they want and press the button to add the item to their cart via ajax.
How do you update the quantity before your make the ajax request. You will have to read the value of the select and then concatenate the data: field. Is this possible with Yii/Ajax or should I revert to plain JQuery?
Your doubt sounds to me a pretty simple javascript function on a HTML element event. Register your function with CClientScript or add it on your element’s HTML options…
In most situations where I’ve wanted to do something similar to what you’re doing I’ve found that it’s enough to use http://www.yiiframework.com/doc/api/1.1/CHtml#ajax-detail in the ajax attribute of a form element using either the ‘update’ or some more specific jquery in the ‘success’ attribute. This ought to give you enough control, and you can just set up a text field to run your ajax action every time its value changes.
Why do you want to update the quantity BEFORE the ajax request? Shouldn’t you do your additions in your controller/model, save it, and then return the result via success?
Thank you for the replies but I’m still stuck, I’m probably overlooking something very simple but it’s driving me crayzeee and I have lost 2 days on it already , here is the code I’m using: