WebSockets protocol vs HTTP

1) Why is the WebSockets protocol better? WebSockets is better for situations that involve low-latency communication especially for low latency for client to server messages. For server to client data you can get fairly low latency using long-held connections and chunked transfer. However, this doesn’t help with client to server latency which requires a new … Read more

CORS: Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true

This is a part of security, you cannot do that. If you want to allow credentials then your Access-Control-Allow-Origin must not use *. You will have to specify the exact protocol + domain + port. For reference see these questions : Access-Control-Allow-Origin wildcard subdomains, ports and protocols Cross Origin Resource Sharing with Credentials Besides * … Read more

ASP.NET MVC controller actions that return JSON or partial html

In your action method, return Json(object) to return JSON to your page. public ActionResult SomeActionMethod() { return Json(new {foo=”bar”, baz=”Blech”}); } Then just call the action method using Ajax. You could use one of the helper methods from the ViewPage such as <%= Ajax.ActionLink(“SomeActionMethod”, new AjaxOptions {OnSuccess=”somemethod”}) %> SomeMethod would be a javascript method that … Read more

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

What is the motivation behind the introduction of preflight CORS requests?

I spent some time being confused as to the purpose of the preflight request but I think I’ve got it now. The key insight is that preflight requests are not a security thing. Rather, they’re a not-changing-the-rules thing. Preflight requests have nothing to do with security, and they have no bearing on applications that are … Read more

How can I post data as form data instead of a request payload?

The following line needs to be added to the $http object that is passed: headers: {‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’} And the data passed should be converted to a URL-encoded string: > $.param({fkey: “key”}) ‘fkey=key’ So you have something like: $http({ method: ‘POST’, url: url, data: $.param({fkey: “key”}), headers: {‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’} }) From: https://groups.google.com/forum/#!msg/angular/5nAedJ1LyO0/4Vj_72EZcDsJ UPDATE To … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)