I have an ASP.net web application with a homepage. There is a search function in the menu bar of my main page in which the user enters a query and presses a button. When the button is pressed, the user's browser goes to the page on which the search results are displayed. This functionality works great.
However, I decided to use jQuery AJAX and jQuery Autocomplete to make the program easier to use. The search works differently from http://example.com/page1.aspx and http://example.com/page2.aspx , but it does not work from http://example.com/subdirectory/index.aspx .
Here is my javascript code for doing autocomplete: (from the main page)
function setupSerialNumberAutocomplete(id) {
$(id).autocomplete({
source: function(request, response) {
$.ajax({
url: "DeviceSelection.aspx/getDeviceFieldAutocomplete",
data: "{ 'text': '" + escape(request.term) + "', 'field': 'SerialNumber' }",
dataType: "json",
type: "POST",
contentType: "application/json",
dataFilter: function(data) { return data; },
success: function(data) {
response($.map(data.d, function(item) {
return {
value: item
}
}))
},
error: function(xhr, status) {
var exception = eval("(" + xhr.responseText + ")");
$("#divStatus").html("Error fetching registration codes list: " + xhr.statusText + " - " + exception.Message + ".");
}
});
},
minLength: 2,
focus: function(event, ui) {
$(id).val(ui.item.value);
return false;
},
select: function(event, ui) {
$(id).val(ui.item.value);
return false;
}
});
jQuery AJAX DeviceSelection.aspx/getDeviceFieldAutocomplete, - ASP.net. DeviceSelection.aspx http://example.com/DeviceSelection.aspx, , , http://example.com/subdirectory/index.aspx , - http://example.com/subdirectory/DeviceSelection.aspx.
?