Implement isSameOrigin() to simplify origin determination

This commit is contained in:
Kijin Sung 2017-03-06 15:11:45 +09:00
parent 14300cbcc3
commit e82e3fb18c
2 changed files with 17 additions and 6 deletions

View file

@ -47,9 +47,7 @@
}
// Check whether this is a cross-domain request. If so, use an alternative method.
var _u1 = $("<a>").attr("href", location.href)[0];
var _u2 = $("<a>").attr("href", url)[0];
if (_u1.protocol != _u2.protocol || _u1.port != _u2.port) return send_by_form(url, params);
if (!isSameOrigin(location.href, url)) return send_by_form(url, params);
// Delay the waiting message for 1 second to prevent rapid blinking.
waiting_obj.css("opacity", 0.0);