change this: *content: {sf_format: 'delete'},*
to this: *content: {sf_method: 'delete'},*
On Tue, Mar 2, 2010 at 7:34 PM, Donald <[email protected]> wrote:
> I've been hitting my head against a wall all day trying to figure out
> why I can't get REST functionality working in my project, and I seem
> to have hit the following problem:
>
> REST worked great when I use symfony generated links with link_to, or
> using symfony generated forms. But I cannot for the life of me get
> REST to work using xhr methods.
>
> I'm currently using Dojo 1.4.1, and I'm trying to delete an entity
> using REST. However, whenever I submit the request to the server using
> xhrPost or xhrDelete, the symfony routing sends me to the "show"
> action and not the "delete" action.
>
> I would greatly appreciate it if someone could take a look at the
> information below and let me know what I'm doing wrong…
>
> Here's the routing:
>
> email_usage_show:
> url: /email/usage/:id.:sf_format
> param:
> module: addressUsage
> action: showEmailAddressUsage
> requirements:
> sf_method: get
> id: \d+
>
> email_usage_delete:
> url: /email/usage/:id.:sf_format
> class: sfDoctrineRoute
> options:
> model: AddressUsage
> type: object
> param:
> module: addressUsage
> action: deleteEmailAddressUsage
> sf_format: json
> requirements:
> sf_method: delete
> id: \d+
>
> Here's the symfony link that *does* work:
>
> <a href="/frontend_dev.php/email/usage/4
> onclick="if (confirm('Are you sure?')) {
> var f = document.createElement('form');
> f.style.display = 'none';
> this.parentNode.appendChild(f);
> f.method = 'post';
> f.action = this.href;
> f.target = 'newPage';
> var m = document.createElement('input');
> m.setAttribute('type', 'hidden');
> m.setAttribute('name', 'sf_method');
> m.setAttribute('value', 'delete');
> f.appendChild(m);f.submit();
> };
> return false;">!!DELETE!!</a>
>
> Here's the dojo xhrPost that *doesn't* work:
>
> dojo.xhrDelete ({
> url: '/frontend_dev.php/email/usage/4',
> handleAs: 'json',
> content: {sf_format: 'delete'},
> load: dojo.hitch(this, this.onDeleteSuccess),
> error: dojo.hitch(this, this.onDeleteFailure)
> });
>
> Here's the FireBug output from the symphony link:
>
> Response Headers
> HTTP/1.1 200 OK
> Date: Tue, 02 Mar 2010 21:55:17 GMT
> Server: Apache
> X-Powered-By: PHP/5.2.11
> Content-Length: 1
> Keep-Alive: timeout=15, max=100
> Connection: Keep-Alive
> Content-Type: text/html
>
> Request Headers
> POST /frontend_dev.php/email/usage/4 HTTP/1.1
> Host: localhost
> User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6;
> en-US;
> rv:1.9.2) Gecko/20100115 Firefox/3.6
> Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/
> *;q=0.8
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 115
> Connection: keep-alive
> Referer: http://localhost/frontend_dev.php/person/3
> Cookie: symfony=50f8abe372aeaf0e80ce559ad926fb9c
>
> Parameters - application/x-www-form-urlencoded
> sf_method delete
>
> Source
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 16
>
> sf_method=delete
>
> Response
> 4
>
> Here's the FireBug output from the dojo xhrPost that *doesn't* work:
>
> Response Headers
> Date: Tue, 02 Mar 2010 22:00:10 GMT
> Server: Apache
> X-Powered-By: PHP/5.2.11
> Content-Length 442
> Keep-Alive: timeout=15, max=73
> Connection: Keep-Alive
> Content-Type: application/json
>
> Request Headers
> Host: localhost
> User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6;
> en-US;
> rv:1.9.2) Gecko/20100115 Firefox/3.6
> Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/
> *;q=0.8
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 115
> Connection: keep-alive
> Content-Type: application/x-www-form-urlencoded;
> charset=UTF-8
> X-Requested-With: XMLHttpRequest
> Referer: http://localhost/frontend_dev.php/person/3
> Content-Length: 84
> Cookie: symfony=50f8abe372aeaf0e80ce559ad926fb9c
>
> Parameters - application/x-www-form-urlencoded
> sf_method delete
>
> Source
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 16
>
> sf_method=delete
>
> Response
> { JSON data for address 4 }
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en