Saturday, April 28, 2012

Re: Interacting with a cakephp rest service using jquery - problem with PUT

Browser support for PUT and DELETE is sketchy.

http://annevankesteren.nl/2007/10/http-method-support
http://amundsen.com/examples/put-delete-forms/

On Sat, Apr 28, 2012 at 4:25 AM, Greg Skerman <gskerman@gmail.com> wrote:
> I will add, that POST and GET works fine... data is passed back and forth as
> expected and cakephp's "magic" takes care of saving of data perfectly fine.
>
>
> On Sat, Apr 28, 2012 at 6:24 PM, Greg Skerman <gskerman@gmail.com> wrote:
>>
>> Hi all,
>>
>> Building a simple tool which uses a cakephp rest service. The client
>> application is the webpage generated by the application, and it reacts to
>> user input such as dragging and dropping things around.
>>
>> I've extended the jquery ajax helper methods to include methods for PUT
>> and DELETE, and these are triggering just fine.
>>
>> The problem is I am unable to get the data back to cakephp to do anything
>> with it.
>>
>> heres the javascript which triggers everything off:
>>
>>             $('div.content-block').droppable({
>>                drop: function(event, ui)
>>                {
>>                   $(this).children('ul').append(ui.draggable);
>>                   // perform the PUT on the db...
>>                   var pilotID = ui.draggable.attr('id').split('-')[1]
>>                   var squadID = $(this).attr('id').split('-')[1];
>>
>>                   $.put('pilots/'+pilotID+'.json',
>>                   {
>>                      "squad_id" : squadID
>>                   }, function() {
>>                      alert('success');
>>                   }).error(function(){
>>                      alert('error');
>>                   }, 'json');
>>
>>
>> as you can see, it is performing a PUT request on the pilots controller
>> which is setup up with default resource map, parse extensions and request
>> handler. Dragging and dropping a pilot from one squad to another correctly
>> triggers a HTTP PUT request, however inspecting $this->request->data and
>> $this->request->input('json_decode') both return empty arrays.
>>
>> I'd appreciate assistance from anyone who has successfully gotten jquery
>> to interact with a cakephp rest api.
>>
>> Cheers :)
>>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: