Getting “net::ERR_BLOCKED_BY_CLIENT” error on some AJAX calls

AdBlockers usually have some rules, i.e. they match the URIs against some type of expression (sometimes they also match the DOM against expressions, not that this matters in this case). Having rules and expressions that just operate on a tiny bit of text (the URI) is prone to create some false-positives… Besides instructing your users … Read more

Can you call ko.applyBindings to bind a partial view?

ko.applyBindings accepts a second parameter that is a DOM element to use as the root. This would let you do something like: <div id=”one”> <input data-bind=”value: name” /> </div> <div id=”two”> <input data-bind=”value: name” /> </div> <script type=”text/javascript”> var viewModelA = { name: ko.observable(“Bob”) }; var viewModelB = { name: ko.observable(“Ted”) }; ko.applyBindings(viewModelA, document.getElementById(“one”)); ko.applyBindings(viewModelB, … Read more

jQuery Upload Progress and AJAX file upload

Uploading files is actually possible with AJAX these days. Yes, AJAX, not some crappy AJAX wannabes like swf or java. This example might help you out: https://webblocks.nl/tests/ajax/file-drag-drop.html (It also includes the drag/drop interface but that’s easily ignored.) Basically what it comes down to is this: <input id=”files” type=”file” /> <script> document.getElementById(‘files’).addEventListener(‘change’, function(e) { var file … Read more

What security risks exist when setting Access-Control-Allow-Origin to accept all domains?

By responding with Access-Control-Allow-Origin: *, the requested resource allows sharing with every origin. This basically means that any site can send an XHR request to your site and access the server’s response which would not be the case if you hadn’t implemented this CORS response. So any site can make a request to your site … Read more

Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request

Exceptions which are thrown during ajax requests have by default totally no feedback in the client side. Only when you run Mojarra with project stage set to Development and use <f:ajax>, then you will get a bare JavaScript alert with the exception type and message. But other than that, and in PrimeFaces, there’s by default … Read more

Same origin Policy and CORS (Cross-origin resource sharing)

Same-origin policy What is it? The same-origin policy is a security measure standardized among browsers. The “origin” mostly refers to a “domain”. It prevents different origins from interacting with each other, to prevent attacks such as Cross Site Request Forgery. How does a CSRF attack work? Browsers allow websites to store information on a client’s … Read more

What does it mean when an HTTP request returns status code 0?

Many of the answers here are wrong. It seems people figure out what was causing status==0 in their particular case and then generalize that as the answer. Practically speaking, status==0 for a failed XmlHttpRequest should be considered an undefined error. The actual W3C spec defines the conditions for which zero is returned here: https://fetch.spec.whatwg.org/#concept-network-error As … Read more