Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Page refresh

  1. #11
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    AJAX can send post data?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yep.
    After the open() call, rather than send(null) or send(''), you should send("name1=value1"); send("name2=value2"); and so on, for as many name/value pairs as you like.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Is there any way to attach that to a link?

    (I suppose you could add an onClick attribute)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #14
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    [...] rather than send(null) or send(''), you should send("name1=value1"); send("name2=value2"); and so on, for as many name/value pairs as you like.
    I don't know if it was your intent, but that reads like a suggestion to call the send method twice or more for a single request.

    To send data in a POST request, one has the option of either composing a query string-like set of data where name/value pairs are combined with an equals symbols (=), and pairs are separated by an ampersand (&). Alternatively, the entity body should be a well-formed MIME message body. In either case, both a Content-Type and Content-Length header should be included in the request headers unless there is very good reason not to include them (and there should never be, in this instance).

    The HTML specification defines the unregistered media type, application/x-www-form-urlencoded for use when taking the first option, though other values are also known (and quite similar).


    Quote Originally Posted by djr33
    Is there any way to attach that to a link?
    Why on Earth bother? Just use a form and be done with it. If you really want the button to look like a link, style it as such.

    Links are for navigation, forms are for user input. Use them both properly. Don't arse around with AJAX when something far more reliable and simple is available instead.

    Mike

  5. #15
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    POST data being sent by a form can be limited, so it's nice to have a couple ways around it.

    I think the best idea is to use a form with a button styled as a link.... good idea.

    Anyway.... I'm just curious, more than really needing a solution.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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