Created
May 2, 2020 15:10
-
-
Save vfontjr/1a305400a481ee5c23835c83593f87a6 to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/jquery-ajax-microsoft-browsers/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlDecode(value){ | |
return $(' | |
').html(value).text(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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