I have solution with two projects. First is Web, second is something else (SecondProject).
In first project(web) I have aspx page and jquery script with AJAX functions that need reference handler that is in second project. How to do that? Code example:
$.ajax({
type: "POST",
url: '<%= ResolveUrl("HandlerInSecondProject/GetDataBySample.ashx?q=' + request.term + '") %>',
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
var obj = data;
response($.map(obj, function (item) {
return {
label: item.Term,
id: item.ID
}
}));
}
});
The second project should also be a web project, otherwise the handler will not be properly hosted by ASP.NET. Once the second project is a web project, the URL
should just refer to the location of the handler on the second web project.
Then, you just need to tell your handler to return json, the
ProcessRequestmethod:When you call this from your jQuery, you should get the result back as json and be able to do with it whatever you like.