How does Google Instant work?

UPDATE: Google have just published a blog article called Google Instant, behind the scenes. It’s an interesting read, and obviously related to this question. You can read how they tackled the extra load (5-7X according to the article) on the server-side, for example. The answer below examines what happens on the client-side: Examining with Firebug, … Read more

Access denied in IE 10 and 11 when ajax target is localhost

Internet Explorer raises this error as part of its security zones feature. Using default security settings, an “Access is Denied” error is raised when attempting to access a resource in the “Local intranet” zone from an origin in the “Internet” zone. If you were writing your Ajax code manually, Internet Explorer would raise an error … Read more

How to encode Doctrine entities to JSON in Symfony 2.0 AJAX application?

With php5.4 now you can do : use JsonSerializable; /** * @Entity(repositoryClass=”App\Entity\User”) * @Table(name=”user”) */ class MyUserEntity implements JsonSerializable { /** @Column(length=50) */ private $name; /** @Column(length=50) */ private $login; public function jsonSerialize() { return array( ‘name’ => $this->name, ‘login’=> $this->login, ); } } And then call json_encode(MyUserEntity);

How to write javascript in client side to receive and parse `chunked` response in time?

jQuery doesn’t support that, but you can do that with plain XHR: var xhr = new XMLHttpRequest() xhr.open(“GET”, “/test/chunked”, true) xhr.onprogress = function () { console.log(“PROGRESS:”, xhr.responseText) } xhr.send() This works in all modern browsers, including IE 10. W3C specification here. The downside here is that xhr.responseText contains an accumulated response. You can use substring … Read more

ASP.NET MVC Ajax.ActionLink with Image

From Stephen Walthe, from his Contact manger project public static class ImageActionLinkHelper { public static string ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string actionName, object routeValues, AjaxOptions ajaxOptions) { var builder = new TagBuilder(“img”); builder.MergeAttribute(“src”, imageUrl); builder.MergeAttribute(“alt”, altText); var link = helper.ActionLink(“[replaceme]”, actionName, routeValues, ajaxOptions); return link.Replace(“[replaceme]”, builder.ToString(TagRenderMode.SelfClosing)); } } You can now type … Read more

Cross-Domain AJAX doesn’t send X-Requested-With header

If you are using jQuery to do your ajax request, it will not send the header X-Requested-With (HTTP_X_REQUESTED_WITH) = XMLHttpRequest, because it is cross domain. But there are 2 ways to fix this and send the header: Option 1) Manually set the header in the ajax call: $.ajax({ url: “http://your-url…”, headers: {‘X-Requested-With’: ‘XMLHttpRequest’} }); Option … Read more