Thursday, October 7, 2010

MTNL broadband not opening certain websites

:) then what to do.. i just got one MTNL TriBand broadband unlimited connection for my home in Palam Colony, New Delhi. Everything was great except that it was not opening certain web links like linkedin.com, assembla.com, cricketnirvana.com most of the time and within two days of installation, frustration was so severe that i looked up for google for any help(mind you MTNL,Delhi people they are awesome at NOT resolving any issues like this)
On a random look out for solution i found two things..
1. Change PrimaryDNS and SecondaryDNS to 208.67.222.222 and 208.67.220.220 respectively
and
2. Change TCP MTU Option(in interface page of ADSL router) to 1400

and Final step, Do a restart (one of the option in 'Maintenance' page)
and see if it works for you.. it worked for me :)

Just for information i am having a ADSL router of Sterlite(Firmware Version :2.11.38.0(UE0.C2)3.9.9.5)(provided by MTNL) and am using my own netgear wifi router on top of it,

Monday, October 4, 2010

How to Stop an Ajax request in prototype.js

Question is what will you do if you are using prototype.js(which is not having any abort method) for making a Ajax request and due to some circumstance you want to abort the ajax request raised. Well one can think that this is a narrow requirement, why will anybody need to do this because in the meantime request will be done and one might be having the response in return from server.

I hit this corner case where page content was loading from an Ajax request and which after rendering was firing another Ajax request to update the paginate-r(which is also self firing the request on response completion), but to my surprise i was not able to control the "Ajax request to update paginate-r" and hence i am creating the self firing request but am not able to destroy them.

And i don;t know for what reason there is no "ajaxRequest.abort()" method. And i found the answer from a narrow corner of http://blog.pothoven.net/2007/12/aborting-ajax-requests-for-prototypejs.html and it worked and just to increase the find-ability of this solution am re-writing the post.

introduce a method abort like this for prototype.js
Ajax.Request.prototype.abort = function(){
this.transport.onreadystatechange = Prototype.emptyFunction(); //prevent state change callbacks from being issues
this.transport.abort(); //abort the XHR
Ajax.activeRequestCount--; //updates the request counter
};

and then in your code
write it somewhere so that it is executed only once
<script>
var cw_paginator_request = null;
</script>

and then to assign the request if null else abort the request and fire a new request, like this
<script>
if(cw_paginator_request != null){
cw_paginator_request.abort();
}
cw_paginator_request = <%=remote_function(:url => {:controller => "some_controller", :action => "update_paginator", :id => @selected_id }) -%>;
</script>

Hopefully it might help somebody in need :)

Honda Civic & A/C problems.

Hello Friends, Got a post again on to Honda Civic (The good old favorite commuter of mine). This car has been doing great except for so...