I have asp.net web site in c#.
On Dropdownlist Onchange()
event i'm calling this jquery function, which throws:
function error(){[native code]}
<script type="text/javascript">
function GetDescription(a) {
alert(a); // the dropdown item selected value
var id = (!isNaN($(a).val())) ? parseInt($(a).val()) : 0;
$.ajax({
type: 'POST',
contentType: "application/json; charset-8;",
url: 'WT.aspx/GetRef',
data: "{ 'id':'" + id + "'}",
success: function (data) {
alert(data);
},
error: function (data) {
alert(Error);
}
});
}
</script>
WT.aspx/GetRef
[WebMethod] public string GetRef(int id) { DataTable dt = new DataTable(); SqlParameter[] p = new SqlParameter[1]; p[0] = new SqlParameter("@RefID", id); dt = dl.GetDataWithParameters("Sp_WT_GetRef", p); string data = dt.Rows[0]["Description"].ToString() +"|"+ dt.Rows[0]["PriceInUSD"].ToString(); return data; }
http://localhost:54576/resources/demos/style.css Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:54576/AutomobileWebApp/WT.aspx/GetRef Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:54576/resources/demos/style.css Failed to load resource: the server responded with a status of 404 (Not Found)
Error
constructor isfunction error(){[native code]}
. Useconsole.log
for debugging and check the network tab of the browser developer tools to check the server response. – undefinedstatic
likepublic static string GetRef(int id)
– Amit Soni