Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var confirmation_req = $.ajax({
type: 'GET',
url: '//path-to-remote-server',
dataType: "text",
contentType: "text/xml",
data: { FormXml: strXml },
dataFilter: function (data, type) {
var start = data.search('">') + 2, strlen = data.search('</long>') - start;
return data.substr(start, strlen);
}
});
var confirmation_req = $.ajax({
type: 'POST',
crossDomain: true,
url: '//path-to-remote-server',
dataType: "text",
data: { FormXml: strXml },
dataFilter: function (data, type) {
var start = data.search('">') + 2, strlen = data.search('') - start;
return data.substr(start, strlen);
}
}).fail(function (jqXHR) {
write_to_log("Ajax submission failed");
write_to_log("Content sent to server: " + strXml);
write_to_log("Status: " + jqXHR.status + '\r\n' + "Status code: " + "Status message: " + jqXHR.statusText);
alert("There was an error retrieving the confirmation number from the server. Please try submitting your form again later.");
}).done(function (data) {
if ($.isEmptyObject(data) || data === "0") {
write_to_log("Empty confirmation number in done function");
write_to_log("Content sent to server: " + strXml);
alert("There was an error retrieving the confirmation number from the server. Please try submitting your form again later.");
} else {
write_to_log("Success! We're done");
set_form_fields(data);
display_confirmation();
}
}).always(function () {
write_to_log("Submitting form");
$("#my_form").submit();
});
function htmlDecode(value){
return $('
').html(value).text();
}
function htmlEncode(value){
return $('
').text(value).html();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.