Can I use AJAX without using POST?

by on December 5, 2009

Q: I am just becoming familiar with AJAX and have copy-pasted the coding for sending GET requests to a PHP program. However, a large part of my website contains a function which handles a few large chunks of data. Some of this data can be upwards of 8,000 characters. I am trying to write a page to use AJAX to create articles, upload pictures all without refreshing the page. How can I do this without using POST? And can POST handle a total of 3MB of data (text only, image uploads are handled separately)?


9 Responses to “Can I use AJAX without using POST?”
  1.  

    I am some what confused. You are asking if you can do this without using POST but then you ask if POST can support 3MB. The amount of data that can be sent from the client to the server is set on the server side so you would have to check with your host or create a page that does php_info() and see what the max upload size is set to.

    As for using AJAX to do GET or POST, you really should be able to use either. You can even cheat in php and use REQUEST and that combines both GET and POST and then you don’t have to worry about how the data comes over.

     
  2.  

    I wanted to use POST in it because POST can handle much more data than GET. I dont know it I typed it wrong or if it was translated wrong. But I know how to send a GET request in AJaX but don’t know if I can do POST, and if so, how.

     
  3.  

    Ok. That gives the answer in PHP side, but what about scripting side? How can I POST variables without a submit?

     
    •  

      If you are using jQuery you can just do jQuery.post() and you can find more information at http://docs.jquery.com/Ajax/jQuery.post

      If you are using another library it will have a method for doing it as well.

       
  4.  

    Thank you. It is certainly a different syntax than I have seen in the httprequest coding heh.

     
  5.  
    Picked as best answer

    Perfect. Thanks. I can impliment this easily.

     
  6.  

    Ok I have spent the better part of 12 hours debugging the code on that last link you sent me to no avail. It does not receive any data at all. It is almost as if it does not make a connection. I even try to get it to link to its own address and no received information. I have a link below, you can check out the script. The button on the page that is supposed to use the script is fully activated (but uses captcha) but for debugging purposes I put a temp button at the very top of the page. Please let me know how I am to fix the bug. Thank you in advance.

    http://ezhousefixes.com/temp/index.php

     
  7.  

    Okay nevermind I just erased “http.send”. And I did confirm that it can handle as much information as I need it to. I ran a flood test into one of the POST variables of over 27,000 char in length and when I printed the Array, it succeeded. Thanks.