0

I've created a form based on edits from another post I found on here, where the HTML form outputs in XML format once the submit button has been clicked. How do I now take this data once transformed and post it to a third-party server via HTTP POST instead of outputting on html?

My code in its current form can be found here. http://jsbin.com/iyokay/15/edit

My knowledge of Javascript isn't great so any code based help would be greatly appreciated.

2
  • Have you tried anything yet? $.ajax({url:"third-party", type:"POST", contentType:"text/xml", data:newXml) Commented Apr 12, 2013 at 13:01
  • No nothing yet. I've been hunting around for a solution without any joy, so resorted to asking a question on here. Commented Apr 12, 2013 at 13:15

1 Answer 1

1

You can send your xml with ajax,

$("#DownloadButton").on("click",function(){
     xml = update();
     $.ajax({
       url : "saveXml.php",
       type:"post",
       data : xml,
       contentType: "text/xml",
       success : function(response){
          alert("xml saved successfully");
       }  
     });
});

replace this $("#DownloadButton").click(update); with above code

Sign up to request clarification or add additional context in comments.

7 Comments

how do i reference in ajax?
well how do I integrate that code into what I already have? Is there an ajax library that has to be referenced?
Don't forget to set the contentType.
@sagamon: you tagged your question jquery, and jQuery has a powerful ajax function. Don't you use it?
@sagamon you don't need any library,, jQuery is enough.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.