Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    838
    Thanks
    15
    Thanked 9 Times in 9 Posts

    Sending XML via $.ajax, but specifing POST name.

    Don't know if the title made any sense, but here's my problem.
    I have the following code:
    Code:
    		$.ajax({
                   //url: "http://sellonline.canadapost.ca:30000"
    			   	 url: "test.php"
                   , type: "POST"
                   , processData: false
    			   , data: xmlDocument
                   , success: function(responsed) {
    				    alert("Returned\n---------------------\n"+responsed);
    			   }
    			   , error:function(xhr,err){
    					alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status+"\ntext: "+xhr.statusText);
    					alert("responseText: "+xhr.responseText);
    				}
    			  
            });
    Which, at present time works fine... the test.php only has
    PHP Code:
    <?php
        print_r
    ($_POST);
    ?>
    which again works fine. Returns the xml document in the $_POST array that I sent.

    However, I need to send this with the key "XMLRequest". As if the XML was in a textarea with name="XMLReqeust".
    Basically, I want to do what they do here. http://sellonline.canadapost.ca/Deve...Interface.html Only via AJAX, which should work, no?

    I've tried data: ({ 'XMLRequest': xmlDocument }) but with no success.

    Is there any way to do this. I've tried searching the jQuery API but they're very limited on how this works. Thanks.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Isn't the format data: "name=value"? So in your case, this should work:

    PHP Code:
     data"XMLRequest=" xmlDocument 


  •  

    Posting Permissions

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