我正在努力让我的HTTP Post在Firefox和IE中运行,
它目前在Chrome中运行良好。
这是我目前的代码:
$(function () {
$('.scPracticeTest').on('click', function (e) {
var guid = jQuery.Guid.New();
var testcode = $(this).attr('testcode');
$.support.cors = true;
$.ajax({
type : 'POST',
url: 'https://sc-practice.content.saville.int/sites/api/Integration/SavilleLegacy/CreateCandidate.ashx',
contentType: 'application/x-www-form-urlencoded',
data: {
clientid: "4D102B05-8949-4B04-A87A-59AC5A88FC65",
username: "practiceintegration",
password: "practiceintegration",
givenname: guid,
familyname: guid,
culturecode: "en-GB"},
success: function (data) {
candidate = $(data).find("accessid").text();
window.location.replace("https://sc-practice.content.saville.int/sites/api/Integration/SavilleLegacy/Assessment.ashx?clientid=4D102B05-8949-4B04-A87A-59AC5A88FC65&username=practiceintegration&password=practiceintegration&accessid=" + candidate + "&testcode=" + testcode + "&returnurl=https://www.savilleconsulting.com/products/test-aptitude-preparation-guides-and-advice/");
},
error: function (data) {
alert(data.statusText);
}
})
})
});
我也有Jquery Guid链接 -
jQuery.extend({
Guid: {
Set: function (val) {
var value;
if (arguments.length == 1) {
if (this.IsValid(arguments[0])) {
value = arguments[0];
} else {
value = this.Empty();
}
}
$(this).data("value", value);
return value;
},
Empty: function () {
return "00000000-0000-0000-0000-000000000000";
},
IsEmpty: function (gid) {
return gid == this.Empty() || typeof (gid) == 'undefined' || gid == null || gid == '';
},
IsValid: function (value) {
rGx = new RegExp("\\b(?:[A-F0-9]{8})(?:-[A-F0-9]{4}){3}-(?:[A-F0-9]{12})\\b");
return rGx.exec(value) != null;
},
New: function () {
if (arguments.length == 1 && this.IsValid(arguments[0])) {
$(this).data("value", arguments[0]);
value = arguments[0];
return value;
}
var res = [], hv;
var rgx = new RegExp("[2345]");
for (var i = 0; i < 8; i++) {
hv = (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
if (rgx.exec(i.toString()) != null) {
if (i == 3) { hv = "6" + hv.substr(1, 3); }
res.push("-");
}
res.push(hv.toUpperCase());
}
value = res.join('');
$(this).data("value", value);
return value;
},
Value: function () {
if ($(this).data("value")) {
return $(this).data("value");
}
var val = this.New();
$(this).data("value", val);
return val;
}
}
})();`
任何想法都将是一个巨大的帮助!