I am trying to use AJAX to allow a user to input an ID number in order to populate another area on my page. I want to use AJAX to accomplish this. I haven't used AJAX that much, especially while using MVC. My AJAX should execute when my checkIdBtn is clicked but every time I click it, it says "The resource cannot be found. Requested URL: /Events/Search". I can't figure out what is wrong with my URL (im guessing it can't find my controller/action method?). My controller is my HomeController and the action method is getEmpInfo. Below is the code for my AJAX:
<script type="text/javascript">
$(document).ready(function () {
$('#CheckIdBtn').click(function () {
var empId = $('#empId').val();
$.ajax({
url: '/Home/getEmpInfo',
contentType: 'application/html; charset=utf-8',
data: { id: empId },
type: 'GET',
dataType: 'html'
})
.success(function (result) {
$('#EmpInfoDiv').html(result);
})
.error(function (xhr, status) {
alert(status);
})
});
});
</script>
http://yourserver/Home/getEmpInfoin browser?The resource cannot be found. Requested URL: /Events/Search: somehow you are callinghttp://yourserver/Events/Search