jQuery ajax only works in IE when the IE debugger is open

It was very annoying. Ajax request not works perfectly in IE. But when developer tool is opened ajax quires are works fine. It was very cumbersome . It happened because IE chache Ajax requests. When Developer tool opened it is always refresh from server.

I get this fixed by making cache false in ajax request.


$.ajax({
type: "GET",
url: url,
dataType: "html",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({}),
cache: false,
success: function (r) {
}
});

I think it might help you.

Login failed for user IIS APPPOOL\DefaultAppPool

Again I got a Error.

Login failed for user iis APPPOOL\Default. I fixed this issue by running following sql script in sql server.


IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = 'IIS APPPOOL\DefaultAppPool')
BEGIN
CREATE LOGIN [IIS APPPOOL\DefaultAppPool]
FROM WINDOWS WITH DEFAULT_DATABASE=[MISDB],
DEFAULT_LANGUAGE=[us_english]
END
GO
CREATE USER [WebDatabaseUser]
FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_owner', 'WebDatabaseUser'
GO

Set your required database as default database.

 

This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

So when I am hosting ASP.NET MVC web site in iis 7 I got following error.

error1

So I followed following steps to get this solved.

Click “Start button”
in the search box, enter “Turn windows features on or off”
in the features window, Click: “Internet Information Services”
Click: “World Wide Web Services”
Click: “Application Development Features”
Check (enable) the features. I checked all but CGI.

Now it is solved. I think it might help you.

let run long runing task in background in javascript

So When I am in javascript development I had a long running javascript method which delays page loading. So I wanted to make it run in background to protect responsiveness of application. So I found Differed execution in Jquery.  Using differed execution we can run functions in background and do another stuffs as we want. And we can pass callback function to execute on after finishing the long running function.

Code Sample on jsfiddle

Get query string values from Javascript

So now I am writing here utility function that i am using to get query string values.

Just Passe the query string name and function will return value.


function queryString(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) return "";
else { var x = results[1]; return x.replace(/%20/gi, ' '); }
}

Find Bootstrap screen size in Javascript

Some times we want to know bootstrap screen size from javascript. When I am developing I needed it and Now I am using following function. Calling it I can get bootstrap screen size like “xs”,”md”,”sm”,”lg”


function findBootstrapEnvironment() {
var envs = ['xs', 'sm', 'md', 'lg'];

$el = $('
<div>');
$el.appendTo($('body'));

for (var i = envs.length - 1; i >= 0; i--) {
var env = envs[i];

$el.addClass('hidden-' + env);
if ($el.is(':hidden')) {
$el.remove();
return env
}
};
}