www.webdeveloper.com
Results 1 to 4 of 4

Thread: PUT and DELETE requests

  1. #1
    Join Date
    Dec 2008
    Posts
    2

    PUT and DELETE requests

    Does anyone know how to send PUT or DELETE HTTP requests in Javascript ? I'm using jQuery as well,.. don't know if there's any way to do it through that.

    Thanks for any insight offered!

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    IO gets and puts:

    Code:
    function IO(U, V) {
        var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
        X.open(V ? 'PUT' : 'GET', U, !1);
        X.setRequestHeader('Content-Type', 'text/html')
        X.send(V ? V : '');
    return X.responseText;
    }

    this deletes a url:
    Code:
    function del(U, V) {
        var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
        X.open( 'DELETE', U, false);
        X.send('');
    return X.status;
    }

  3. #3
    Join Date
    Dec 2008
    Posts
    2
    Thanks for the reply.

    The URL for my PUT request is actually doing some server-side logic and then redirecting to a new URL.

    I tried the above code, and it looks like it executes an AJAX request.. i.e. asynchronous,.. so it's not changing the web page.

    I guess what I'm looking for is just a straight synchronous request to a URL using a method of 'PUT', so something like this:

    window.location.href = (some URL);

    ..but that would execute it with a method of 'PUT' instead of 'GET'.

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by jwleeman View Post
    I guess what I'm looking for is just a straight synchronous request to a URL using a method of 'PUT', so something like this:

    window.location.href = (some URL);

    ..but that would execute it with a method of 'PUT' instead of 'GET'.
    page requests always use GET.
    i've never heard of doing what you request, nor seen code to support it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles