Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i m searching this error from two regular days.After many changes in web.config.
ajax post method not working for web method.

It shows below error in console

http://localhost:5500/ProfileEdit.aspx/GetState Failed to load resource: the server responded with a status of 404 (Not Found)

I have a web method with name GetState that was working in visual studio 2012 and it's still working in Visual Studio 2012 but after merging file in visual studio 2013 it's not working and shows above error.

I tried to change ajax latest dll but it also not working..shows same error as above..


if anyone have solution then Kindly help me.

Thanks.
Posted
Updated 6-Apr-15 6:27am
v2

1 solution

Why not writing just
JavaScript
if (!Sys) {
   // you cannot use Sys
}

Remember that Sys is also an object. In this approach, you make no difference between undefined and null (different objects in JavaScript), but in many cases this difference does not have to be made.

The rest of your post is not quite clear to me, sorry. Your follow-up questions will be welcome.

—SA
 
Share this answer
 
Comments
itsathere 7-Apr-15 2:05am    
when and where i'll use ur if condition..
I have below method in javascript

<script type="text/javascript">
$("#ContentPlaceHolder1_ddlCountry").change(function () {
debugger;
var end = this.value;
$('#<%=hdnCountry.ClientID%>').val(end);
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ProfileEdit.aspx/GetState",
//url: '<%= ResolveUrl("~/ProfileEdit.aspx/GetState") %>',
data: "{'countryID':'" + end + "'}",
dataType: "json",
success: function (data) {
debugger;
$('#<%=ddlState.ClientID%>').empty();
$('#<%=ddlState.ClientID%>').append($("<option></option>").val(0).html('--Select--'));
$.each(data.d, function (key, value) {
$('#<%=ddlState.ClientID%>').append($("<option></option>").val(value.ID).html(value.Name));
});
var items = $("#ContentPlaceHolder1_ddlState option").length;
if (items == 1) {
$('#<%=ddlCity.ClientID%>').empty();
$('#<%=ddlLocality.ClientID%>').empty();
$('#<%=ddlCity.ClientID%>').append($("<option></option>").val(0).html('--Select--'));
$('#<%=ddlLocality.ClientID%>').append($("<option></option>").val(0).html('--Select--'));
}
},

error: function (data) {
alert("Error");
}
});
});
</script>

and below is the code behind method

//[WebMethod]
[System.Web.Services.WebMethod]
public static StateDetails[] GetState(string countryID)
{
List<statedetails> details = new List<statedetails>();
try
{
int cid = Convert.ToInt32(countryID);
HttpResponseMessage response = objCRUD.Get("api/CountryState/0/0/" + cid); // Controller Name
if (response.IsSuccessStatusCode)
{
var Module = response.Content.ReadAsAsync<List<countrystatemodel>>().Result;
if (Module.Count() > 0)
{
DataTable dt = ToDataTable(Module);
foreach (DataRow dtrow in dt.Rows)
{
StateDetails state = new StateDetails();
state.ID = Convert.ToInt32(dtrow["ID"].ToString());
state.Name = dtrow["Name"].ToString();
details.Add(state);
}
}
}
return details.ToArray();
}
catch (Exception ex)
{
throw ex;
}
}
Sergey Alexandrovich Kryukov 7-Apr-15 8:58am    
And? If you have a question on that, please move this sample from comment to question using "Improve question", format it properly and explain your concerns.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900