I am trying to save data using web method. But it shows an error like method not found.
function InsertMasterCourse() {
var data = {};
data.Name = $('[id$=txtName]').val();
$.ajax({
type: 'POST',
url: '<%= ResolveUrl("~/MasterService.asmx/InsertMasterCourse") %>',
data: "{data:" + JSON.stringify(data) + "}",
contentType: "application/json; charset=utf-8",
dataType: 'json',
async: true,
success: function (response) {
$('#txtName').val('');
},
error: function (response) {
alert(response.statusText);
}
});
return false;
}
In .asmx
[WebMethod()]
[ScriptMethod()]
public static void InsertMasterCourse(Master_CourseBLL data)
{
data.CollegeId = 1;
data.Status = "Active";
data.CreatedOn = DateTime.Now;
data.UpdatedOn = DateTime.Now;
data.Save(true);
}
In my web.config I have add http get and post request as follows
<location path="MasterService.asmx">
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
If i check google chrome console, it shows error like InsertMasterCourse.aspx not found. .aspx added with my web service method. How to solve it.