Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

POSTing with the builtin ajax functions?

ithcyithcy New
edited April 2006 in Vanilla 1.0 Help
i'm thinking it's not possible, but is it?
i would like to ajax some data to a php script via POST instead of GET.


  • ithcyithcy New
    edited April 2006
    nevermind, i modified ajax.js to handle POSTs, but it didn't help me anyway :)
  • ithcyithcy New
    edited April 2006
    actually it does exactly what i want it to do.
    hey Mark, i know you hate javascript, so if you're interested, i changed the LoadData function in DataManager in js/ajax.js with this:

    this.LoadData = function(DataSource,postVars) { if(undefined === postVars) postVars = false; // Debug // document.location = DataSource; var Request = this.InitiateXmlHttpRequest(); if (Request != null) { try { Request.onreadystatechange = this.CreateDataHandler(Request); if(!postVars) {"GET", DataSource, true); Request.send(null); } else {"POST", DataSource, true); Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); Request.setRequestHeader("Content-length", postVars.length); Request.setRequestHeader("Connection", "close"); Request.send(postVars); } } catch(oc) { alert(oc); } } }

    that way it doesn't break any part of the site that's already using ajax, and it allows POSTing by calling it with post variables (i.e. "s=some%20urlencoded%data") as the second argument.
  • MarkMark Vanilla Staff
    I'd say instead of altering the Vanilla js, just write your own version of the DataManager (named something else, of course) and include/use that on your pages. That way you will get all of the functionality you want, and it won't conflict with vanilla's js code.

    I just spent the entire evening going through all of Vanilla's javascript changing stuff. I don't feel like going back into the woods right about now, sorry :)
This discussion has been closed.