#289 enhancement
Pablo Bustos

Allow PUT, DELETE and other HTTP methods on ajax requests

Reported by Pablo Bustos | August 18th, 2008 @ 10:58 PM

"request" function of Ajax.Request class, simulate other verbs (e.g. DELETE, PUT, HEAD, etc) over post.

Why restrict to only get and post requests?

To enable prototype use servlets of my project (that requires DELETE and PUT methods), as a patch, I replaced in that function this line:


      this.transport.open(this.method.toUpperCase(), this.url,
        this.options.asynchronous);

by this:


      this.transport.open(this.options.method.toUpperCase(), this.url,
        this.options.asynchronous);

and works perfectly.

Comments and changes to this ticket

  • John-David Dalton

    John-David Dalton August 18th, 2008 @ 11:43 PM

    • State changed from “new” to “invalid”
  • Pablo Bustos

    Pablo Bustos August 19th, 2008 @ 04:50 AM

    I could not find the answer in that reference, why restrict to only GET and POST?

    Do you know if the _method param corresponds to a w3c standard?

    How can I manage a _method param from a java servlet? Servlets cannot process post and get params concurrently...

  • John-David Dalton

    John-David Dalton August 19th, 2008 @ 04:53 AM

    • State changed from “invalid” to “new”
    • Assigned user set to “Tobie Langel”
  • Tobie Langel

    Tobie Langel August 21st, 2008 @ 12:46 AM

    DELETE and PUT request are not implemented in all supported browsers.

  • Tobie Langel

    Tobie Langel August 21st, 2008 @ 12:46 AM

    • State changed from “new” to “enhancement”
    • Tag set to ajax, needs_docs, needs_patch, needs_tests
  • Pablo Bustos

    Pablo Bustos August 21st, 2008 @ 03:34 AM

    I'd like to access a REST WS using ajax, and, as a rest service, all resources are accessed with a generic interface (e.g., HTTP GET, POST, PUT, DELETE).

  • Tobie Langel

    Tobie Langel August 22nd, 2008 @ 02:14 AM

    Sure, only, as I mentioned, using DELETE and PUT isn't possible in some of the supported browsers, hence the current work-around.

    Determining which current browsers support what warrants tests, so those would be welcomed.

  • Mark Caudill

    Mark Caudill August 24th, 2008 @ 08:39 PM

    Here is a good starting point for this: http://annevankesteren.nl/2007/1...

    Firefox “supports” the methods from RFC 2616 and RFC 2518, except for TRACE. That method throws an exception for security reasons. All the supported HTTP methods are case-insensitively matched against and uppercased prior to the request.

    Opera has an issue with OPTIONS: the request never finishes loading. (In earlier versions of Opera it is converted to GET.) For known methods it performs a case-insensitive match just like Firefox. The known methods are GET, HEAD, POST, PUT, and DELETE. HEAD and PUT never have a response entity body. All other methods, including custom, result in GET requests.

    IE has probably the weirdest implementation. It performs a case-insensitive match against a list of supported methods, just like the other browsers. However, only for GET, POST, and PUT is the input actually uppercased before the request. So get results in GET, but head results in head. In this way, it supports RFC 2616 and RFC 2518 with TRACE and CONNECT as exceptions. If you use HEAD (uppercase) there will not be any response body. Methods not supported by IE will cause an exception to be raised. (This could be different for prior versions of IE.)

  • David Burger

    David Burger September 5th, 2008 @ 05:01 AM

    On line 83 of ajax.js which currently looks like this:

    if (!['get', 'post'].include(this.method)) {
    
    

    Why not allow 'head' requests? I understand the problem with 'put' and 'delete' may be that most browsers don't support them. Surely most browsers support head.

  • Mark Caudill

    Mark Caudill September 5th, 2008 @ 05:55 AM

    David: Opera doesn't interpret HEAD correctly at all. IE does have problems, but I'm not sure how much that would affect the actual response by the server (with a lowercase 'head' request).

  • John-David Dalton
  • Damien Carol

    Damien Carol January 6th, 2009 @ 09:09 AM

    Microsoft documentation about RESTful Web Services details this tricks : Using the custom header "X-HTTP-Method-Override" in this way :

    
    POST /bookmarkservice/skonnard/bookmarks/123 HTTP/1.1
    
    X-HTTP-Method-Override: DELETE
    

    But for your problem you can do like me.

    
    
       /** By damien to disable PUT/DELETE over POST */
        /*if (!['get', 'post'].include(this.method)) {
          // simulate other verbs over post
          params['_method'] = this.method;
          this.method = 'post';
        }*/
    
    

    I use prototype.js to consume RESTful Web Services. I put in comment from line 1193 to 1198. With this solution this work perfect with Firefox 3.0 but you need to do tests with other browser.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 01:54 AM

    • Tag changed from ajax, needs_docs, needs_patch, needs_tests to needs_docs, needs_patch, needs_tests, section:ajax

    [not-tagged:"ajax" tagged:"section:ajax" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:25 AM

    • Tag changed from needs_docs, needs_patch, needs_tests, section:ajax to missing:documentation, needs_patch, needs_tests, section:ajax

    [not-tagged:"needs_docs" tagged:"missing:documentation" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:26 AM

    • Tag changed from missing:documentation, needs_patch, needs_tests, section:ajax to missing:documentation, missing:tests, needs_patch, section:ajax

    [not-tagged:"needs_tests" tagged:"missing:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:28 AM

    • Tag changed from missing:documentation, missing:tests, needs_patch, section:ajax to missing:documentation, missing:patch, missing:tests, section:ajax

    [not-tagged:"needs_patch" tagged:"missing:patch" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:36 AM

    • Tag changed from missing:documentation, missing:patch, missing:tests, section:ajax to missing:documentation, missing:patch, needs:tests, section:ajax

    [not-tagged:"missing:tests" tagged:"needs:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:37 AM

    • Tag changed from missing:documentation, missing:patch, needs:tests, section:ajax to missing:documentation, needs:patch, needs:tests, section:ajax

    [not-tagged:"missing:patch" tagged:"needs:patch" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:38 AM

    • Tag changed from missing:documentation, needs:patch, needs:tests, section:ajax to needs:doc, needs:patch, needs:tests, section:ajax

    [not-tagged:"missing:documentation" tagged:"needs:doc" bulk edit command]

  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    • Assigned user cleared.

    [responsible:none bulk edit command]

  • XC31Kimberley

    XC31Kimberley February 4th, 2010 @ 10:04 AM

    • Tag cleared.

    A lot of various studens understand techniques of business term paper creating, nevertheless this doesn't mean they are able compose supreme quality research papers, however a custom writing service could help to write the essay topic of great quality and demonstrate writing skills of students.

  • Peter

    Peter February 10th, 2010 @ 01:08 AM

    Some browsers don't support certain (valid) HTTP 1.1 methods.
    Some REST-based web services require certain (valid) HTTP 1.1 methods (and won't truck any of this 'special _method param' nonsense)

    Something will break one way or the other. Please impelement the following so at least the option of which way to go is in the developers hands, not prototypes.

    diff -Naur prototype.js.orig prototype.js
    --- prototype.js.orig 2010-02-10 13:03:00.000000000 +1300 +++ prototype.js 2010-02-10 13:02:18.000000000 +1300 @@ -1390,11 +1390,6 @@

     this.method = this.options.method;
     var params = Object.clone(this.options.parameters);
    
    • if (!['get', 'post'].include(this.method)) {
    • params['_method'] = this.method;
    • this.method = 'post';

    - }

     this.parameters = params;
    
     if (params = Object.toQueryString(params)) {
    

    @@ -1417,7 +1412,7 @@

       this.transport.onreadystatechange = this.onStateChange.bind(this);
       this.setRequestHeaders();
    
    • this.body = this.method == 'post' ? (this.options.postBody || params) : null;
    • this.body = this.method == 'post' ? (this.options.postBody || params) : this.options.postBody; this.transport.send(this.body);

      / Force Firefox to handle ready state 4 for synchronous requests / @@ -1443,7 +1438,7 @@ 'Accept': 'text/javascript, text/html, application/xml, text/xml, /' };

    • if (this.method == 'post') {

    • if (['post', 'put'].include(this.method)) { headers['Content-type'] = this.options.contentType +
       (this.options.encoding ? '; charset=' + this.options.encoding : '');
      
  • Peter
  • erere

    erere July 22nd, 2010 @ 07:54 AM

    • Importance changed from “” to “”

    24 Hour Hazwoper replica watches Training Course fake watches now offers watches you attractive bulk replica rolex discounts on all cartier their training courses breitlingthey provide,

  • erere

    erere July 22nd, 2010 @ 07:59 AM

    • Importance changed from “” to “”

    To be qualified replica handbags for the category fake handbags of discount you need handbags to be louis vuitton handbagsgroups.

  • asdasd

    asdasd August 17th, 2010 @ 08:54 AM

    This will be solved when we modify the way the dom:loaded event is triggered.cheap dvds

  • liushengquan1

    liushengquan1 December 30th, 2010 @ 07:38 AM

    I used to think that Cheap cheap uggs UK were the ugliest I had ever seen.cheap ugg boots You can wear Mini ugg classic tall boots On Saleon the coldest day and your feet will be warm or you can wear them on the hottest day and your feet won't sweat.

  • liushengquan01
  • yyellower

    yyellower March 20th, 2011 @ 12:05 PM

    Discounted Designer Watches At TheWatchery.com, Luxury Watches From Tag Heuer, Movado, Brietling, Ebel, Corum, Cartier, Omega and Much More.Designer Watches Store | Mens & Ladies Designer Watches | Buy Fashion Designer Men's Watches From Burberry, Armani, D&G, Ellesse, DKNY, Fossil and Much http://discountwatchoutlet.biz

  • sinchenming
  • poloralphlauren

    poloralphlauren May 6th, 2011 @ 09:10 AM

    Do you know if the method param corresponds to a w3c standard?How can I manage a method param from a java servlet? Servlets cannot process post and get,ralph lauren shirts,wholesale nike shoes,nike soccer cleats,abercrombie outlet,new era hats,oakley sunglasses,polo outlet

  • chrisboa
  • laptops batteries

    laptops batteries August 18th, 2011 @ 02:26 AM

    Should I Remove theinspiron 1525 battery For A Desktop Replacement Laptop?Well,when using a laptop as a desktop replacement the inspiron 6400 battery should not be left in for long periods of time.The laptop will over time discharge the inspiron 1501 battery.Remove the hp pavilion dv6000 battery – making sure that it is charged to 40% and store it in a dry,warm place.Ensure that battery hp g60 is wrapped protectively and nothing will be dropped on it.The dv2000 battery should be re-installed every 3-4 weeks and allowed to fully discharge.Leaving dv5 battery in storage for longer than this without using could cause the battery to fully discharge as the circuitry of the dv9000 battery itself consumes power.Leaving the hp dv7 battery in a laptop while using an electrical outlet for long periods of time will keep the hp 484170 in a constant state of charging up and that will reduce the life cycle of the dell d620 battery.Remember that when you have removed the dell d630 battery from a laptop while using with an electrical outlet the automatic nv52 backup is no longer functional.For bps9 and bps8 battery drivers,they all can be installed in all xp/vista/windows7 32 bits operating system laptops; for bps12 till follow-up models battery drivers,such as bps13 they all can be installed in all vista/windows7 32 bits and 64 bits operating system laptops.A new pa3534u usually comes in a discharged condition with a very low capacity.It is highly recommended to fully charge new dell xps m1210 battery packs before use.A new dell 1545 battery pack needs to be circled (fully discharged and recharged) three to eight times to reach its optimum performance. Rechargeable1520 battery will undergo self-discharging when left unused for a long period of time. Thus,it should always be stored in a fully charged state and kept in a cool,dry and clean place. To maintain the optimum performance of a hp dv4 battery pack,it is highly recommended to circle (fully discharging and recharging) it at least once a month.

  • xiao123

    xiao123 September 11th, 2012 @ 04:16 AM

    louis vuitton outlet You can not think , louis vuitton handbags outlet as the history and status of the world's top luxury Louis Vuitton can imagine to is common the top of the state symbol.Money is that it allows you to have what you want , and the value of the louis vuitton outlet store , to better reflect the value of money .Here , you can effortlessly understand LV counter , and then according to their own conditions , choose the most suitable for the LV store sales .louis vuitton outlet online If you want to buy LV supplies , you can visit the online store of Louis Vuitton store , if you do not know louis vuitton wallets online store website , you can also enter to search . Combines many functions in one , the Louis Vuitton store magic is not saying much .

  • Jason Westbrook
  • mali

    mali February 2nd, 2015 @ 07:40 AM

    Hello!

    Coach Outlet Store Online

    Our Hearts Nearly Exploded While Rounding Up This Valentine's Day Cuteness For Kids

    Coach Factory Outlet


    9 Celebrity Winter Looks You Can Get For Under $100: Taylor's Beanie, More

    Coach Outlet Online


    All We Have To Say Is Kristen Stewart's Cute Cropped Sweater Is Only $30

    Coach Factory Online Sale


    14 Up-And-Coming Hot Hollywood Dudes You Need To Know

    Coach Factory Outlet Store


    6 Brands With Awesome Black Leggings That Don't Turn See-Through After 1 Wash

    Michael Kors Outlet 90% Off Sale


    Extra 10% Off Sale At Bluefly Comes Out To 45% Off Total-And They've Got Burberry

    Red Bottoms Shoes


    I want to call this bag rock-studded, but it's really more geode-studded, isn't it?

    Michael Kors Outlet Online


    York City office from February 4-8, with the live auction set for 1 p.m. on February 9

    Michael Kors Outlet


    Here's British model, and, by some reports, actress Amy Willerton, toting her Prada bag around Park City.

    Louis Vuitton Outlet


    heading into a taping of Watch What Happens Live in NYC with a fully rockstudded Valentino satchel.

    Coach Outlet Store Online


    which seems most Kyra Sedgwick-appropriate.

    Coach Outlet Store


    Herschel Supply Co. Spring 2015 Coach Store Online

    Coach Outlet


    Groundhog Day may not be an official holiday

    Coach Outlet Factory Online


    Kylie and Kendall Jenner and Topshop? Now You're Talking

    Coach Outlet Online


    The New Spring Bags You'll Have Forever

    Coach Handbags


    3 Wedding Gowns From the Couture Shows-and 4 More Elie Saab Dresses You Could Totally Get Married In

    Coach Factory Outlet


    This Bar Saves Lives, a one-for-one firm that delivers food to children in need

    Coach Outlet Store Online


    Denmark at Hong Kong Fashion Week last Wednesday.

    Coach Outlet


    Scared of Monday? Did you have that not in the pit of your stomach last night?

    Coach Outlet Store


    morning that in the second quarter, which ended Dec. 27, sales dropped 14 percent to $1.22 billion.

    tiffany and co


    Coach's new design concept have been significantly outperforming old locations.

    Coach Factory


    Coach's Sales Continue to Plummet, But the Relative Success of Its New Stores Offers Hope

    Coach Outlet Store Online


    Taken in a vacuum, Coach's sales numbers don't look too hot right now.

    Coach Outlet


    Coach CEO Victor Luis says its revamped stores are significantly outperforming the rest.

    Coach Factory


    Yes, I think I need these clogs to wear with lots of fair isle knits and vintage Edwardian blouses and woven leather belts!

    Valentino Shoes


    The transformation of Saint Valentine's Day over many years has turned this holiday into a massive marketing monster

    Hermes Belts


    Ousted American Apparel founder Dov Charney isn't ready to let go of the company, according to an article from today's

    Kate Spade Outlet


    In addition to closing those stores, the company will also shutter the 12 locations of Jack Spade

    Kate Spade Handbags


    Say goodbye to the affordable Kate Spade shop - The Cut

    Kate Spade


    Say good-bye to Kate Spade Saturday's colorful, wallet-friendly offerings - as least as you know them now.

    Kate Spade Outlet Online


    previously starred in a solo Chanel campaign.

    Michael Kors Outlet Online


    While just about anything is better than staring at a pile of tangled cords.

    Michael Kors Outlet


    New York-based section of the PurseBlog team spent the day at home with our laptops yesterday

    Michael Kors


    this Zen Collection Cord Corral ($65) is downright lovely to look at.

    Michael Kors Outlet


    which is much smoother and might wear better over the years?

    Michael Kors Outlet Online Sale


    And right now this look just feels right.

    Michael Kors Outlet Online


    you're probably aware that the Sundance Film Festival is taking place as we speak.

    Outlet Michael Kors Online


    photos of bags around here. We review bags

    Michael Kors Outlet 90% Off Sale


    make a final order (or two or three), so consider including this Floral Lazer Cut Skirt ($89).

    Louis Vuitton Outlet Store


    Paris Fashion Week 2015: Chanel works its magic in Karl Lagerfeld hothouse

    Louis Vuitton Outlet Online


    For the second time an Metiers d'Art show clashes with a major fashion event

    Louis Vuitton Outlet Store


    4 Super Bowl Outfits for Every Type of Football Fan

    Louis Vuitton Handbags


    Not Another One! Find Out Which Fashion Brand is Closing Its Doors Now

    Louis Vuitton


    Here's a trend I can fully commit to!

    Louis Vuitton Outlet


    official website. We offer Insurance, Savings, Investments & Retirement plans

    Giuseppe Zanotti Shoes


    Joe Zee Talks About The Least Glamorous Part Of His Job And Just Being A Badass Canuck

    Chanel Handbags


    Moon tote and its audaciously architectural shape is striking and brilliant.

    Coco Chanel Handbags


    the other from Chanel.I know what you all must be thinking

    The North Face Outlet


    dorky heavy-heeled wooden clogs and sandals this season. This editorial styled by Geraldine Saglio from Vogue Paris's

    North Face Outlet Online


    Favorite Shoes: Manolo Blahnik BB Pumps

    Hermes Bag


    Heritage Auctions Valentine's Day Luxury Handbag & Accessories Auction

    Burberry Outlet Online


    The 6 Hottest Curly-Hair Color Trends Of 2015

    Burberry Handbags


    Victoria Beckham is nothing if not a woman of impeccable taste, so, of course,

    Co Co Chanel Outlet


    And right now this look just feels right.

    Prada Outlet


    Prada S.p.A. is an Italian luxury fashion house, specializing in ready-to-wear leather and fashion accessories, shoes, luggage.

    Prada Handbags


    Shay Mitchell & Her BFF Curated A Jewelry Collection For Capwell + Co.

    Prada Handbags Outlet


    Sunglasses can give you instant James Dean cool, Audrey Hepburn glamour

    Marc By Marc Jacobs


    is now also available for purchase on Zappos Couture.

    Celine Handbags


    In this week's edition of Snobgrams, Kelly lives the Cali life while Tina soaks up some rays and showcases a classic bag!

    Ray-Ban Sunglasses


    The corporate world has its fair share of pros and cons-there's the consistency of a set daily schedule

    True Religion


    Khloe Kardashian at the Gym Leads Today's Star Sightings

    Oakley Sunglasses


    It's morning. You've had your first cup of coffee, and you step out the door.

    Ralph Lauren Outlet


    Coco wants to meet, plus more fascinating celebrity Twitter posts and words of wisdom below.

    tiffany and co


    The World's No.1 Destination For Affordable Eyewear
    Get 15% Off Anything You Buy Today!

    Ray-Ban Sunglasses


    Women's Designer Sunglasses

    Oakley Sunglasses


    The evolution of fringe has been one of fascination for me.

    Oakley Vault


    so you can easily find a pair to flatter you. Free Shipping

    Ray-Ban Outlet Store Online


    Today's fashion news includes the cultural implications of the recent Men's Fashion Week...

    Cheap Oakley Sunglasses


    Check out the entire selection of sunglasses on Amazon, including top styles from popular brands.

    Abercrombie


    Today's fashion news includes an interview with Karl about the latest Chanel collection...

    Hollister Clothing Store


    Sunglasses - Name Brand Designer Shades & Sport Sunglasses from TOP BRANDS like Ray Ban

    Cheap Oakley Sunglasses


    Flat Matte Reflective Revo Color Lens Large Horn Rimmed Style Sunglasses

    Cheap Ray-Ban Sunglasses


    This season's Firenze4Ever theme was Obsessions. As women

    Abercrombie And Fitch


    Luisa via Roma Firenze4Ever Style Lab, Part 3: Obsess to Impress

    Abercrombie Clothes


    The Pocket Change Shopping Blog is your one-stop

    Toms Outlet


    Timberland: The brand was founded by Nathan Swartz in 1973 and quickly became known for its durable

    Celine Handbags


    Ever since we started seeing some of our favorite celebrities like Beyonce and Cara Delevingne

    Ray-Ban Sunglasses


    Sunglasses are an essential tool in safeguarding the health of your eyes and the surrounding tissue.

    Polo Ralph Lauren Outlet Online


    Would You Shop a Kendall and Kylie Jenner Topshop Collab?

    Polo Ralph Lauren Outlet


    The Shoes I'm Obsessed With For Spring: a moodboard

    Tory Burch Outlet


    and I am currently weighing my options. In years past I have loved my Swedish Hasbeens and Dr. Scholls

    Tory Burch Shoes


    Now Dreading: Kate Spade Saturday Is Closing Its Stores

    Nike Air Jordan


    How to Understand Football Like a Boss: ESPN's Sara Walsh Breaks it Down

    Valentino Shoes


    The latest round of Haute Couture shows has just concluded in Paris for Spring 2015

    Toms Shoes Outlet Online


    The Dreamiest Looks From the Paris Haute Couture Shows

    True Religion Jeans


    We All Have Black Booties, Right? 25 Ways to Style Them

    True Religion Outlet


    30 Outfits That'll Make You Want to Wear Black Ripped Jeans Every Day

    True Religion Jeans


    See How Your Favorite Stars Bundled Up In Style at Sundance

    Red Bottoms Shoes


    I love my Classic Maxi to pieces and I'm always contemplating which large Chanel bag I should acquire next. Who said fancy had to be undersized? The beauty of a large bag is the standards it meets as an everyday bag, especially one you don't have to swap out on a daily basis. Selections from the Classic and Reissue Collections are Chanel enthusiast favorites, and they do tend to overshadow its just as fashionable handbag relatives.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages