jquery - Using Javascript to POST xml to api -
i'm trying post xml data , redirect current page, can't seem work.
when this:
<form action="http://onehouse.freshdesk.com/helpdesk/tickets.xml" method="post">
it works , posts data website want to.
however, leads user xml page want post , have redirect current contact form page , have success message of kind.
i've tried using:
function loadxmldoc() { var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("mydiv").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("post","http://onehouse.freshdesk.com/helpdesk/tickets.xml",true); xmlhttp.send(); }
i don't errors in console, not post the freshdesk website want to. know i'm doing wrong?
this example on how post jquery:
var data = '<helpdesk_ticket>' + '<description>this test</description>' + '<email>sample@example.com</email>' + '</helpdesk_ticket>' $.support.cors = true; $.ajax({ url: 'http://onehouse.freshdesk.com/helpdesk/tickets.xml', type: 'post', crossdomain: true, data: data, datatype: 'text', username: 'username1', password: 'password1', success: function (result) { alert(result); }, error: function (jqxhr, transtatus, errorthrown) { alert( 'status: ' + jqxhr.status + ' ' + jqxhr.statustext + '. ' + 'response: ' + jqxhr.responsetext ); } });
Comments
Post a Comment