I have a http handler file in following directory of my application
I am referring this handler from common.js
file using jQuery ajax and c
Instead of relative path (../../Common/Handlers/CommonHandler.ashx), you can start your path from root(/Common/Handlers/CommonHandler.ashx). So it will work for any page:
function GetMessage(key) {
var message = '';
$.ajax({
type: 'POST',
url: '/Common/Handlers/CommonHandler.ashx', /*Working for EmoloyeeProfile.aspx but not for StoresSummary.aspx*/
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: { 'MessageKey': key },
success: onSucess,
error: OnFailed,
async: false
});
function onSucess(res) {
message = res;
}
function OnFailed(res) {
alert('failed');
}
return message;
}