I'm a little new to Ajax / Jquery, so I apologize if this is a simple question, but I just couldn't figure it out.
I am using CakePHP and jQuery.
I want to save the link, label and description into a table by pulling out "innerHTML" from the HTML page. I can not present the data in the expected format - this is the format that the controller expects.
I am extracting data from html, html looks like this:
<div class="listing"> <ul> <li class="link">www.yahoo.com</li> <li class="label">Yahoo</li> <li class="description">This is Yahoo home page</li> </ul> </div> ...
I can parse the HTML and get my โlinksโ, โlabelโ and โdescriptionโ.
But when I send data to the controller, I canโt figure out how to get the data in the expected format.
After transferring data to variables using JavaScript (jQuery), I submit it using the following jQuery function:
$.post("/links/save", {link: link, label: label, notes: description});
When data is placed in the controller, the data format is:
( [form] => Array ( [link] => www.yahoo.com [label] => Yahoo [description] => This is Yahoo home page ) )
The format that the controller expects from data:
( [data] => Array ( [Link] => Array ( [link] => www.yahoo.com [label] => Yahoo [description] => This is Yahoo home page ) ) )
I know that I can take the data as it is and put it in the correct format in the controller, but it seems that this is not necessary.
Can someone please tell me how to manipulate data in jQuery so that it is placed as the controller expects it?