[Solved] ASP.Net jQuery Ajax Call Error: 500 (Internal Server Error)

Last Reply 16 days ago By dharmendr

Posted 16 days ago

Dear Sir

I am trying this but getting error.

POST https:iig.com/GetGoodsDesc 500 (Internal Server Error)

In Webservice.asmx

    [WebMethod]
    public List<ListItem> GetGoodsDesc(string GoodsCode)
    {
        List<ListItem> items = new List<ListItem>();
            string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;

        HttpContext context = HttpContext.Current;
        string query = "SELECT GOODS_SUB_DESC FROM CM_GOODS_DETAIL WHERE GOODS_GRP_CODE=@GoodsCode";
        using (OracleConnection con = new OracleConnection(conString))
        {
            OracleCommand cmd = new OracleCommand(query, con);
            cmd.Parameters.Add("@GoodsCode", GoodsCode);
            con.Open();
            OracleDataReader sdr = cmd.ExecuteReader();
            while (sdr.Read())
            {
                items.Add(new ListItem { Text = sdr["GOODS_SUB_DESC"].ToString(), Value = sdr["GOODS_SUB_DESC"].ToString() });
            }
            items.Insert(0, new ListItem { Text = "Please Select", Value = "0" });
            con.Close();
        }

        return items;
    }

 

<script type="text/javascript">
    $(function () {
        $("[id*=ddlGoodsGroupCode]").change(function () {
            try
            {
                var row = $(this).closest("tr");
                var value = $(this).find('option:selected').val();
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "IIGService.asmx/GetGoodsDesc",
                    data: "{GoodsCode:'" + value + "'}",
                    dataType: "json",
                    success: function (Result) {
                        Result = Result.d;
                        var data = [];
                        for (var i = 0; i < Result.length; i++)
                        {
                            var selectOption = $(document.createElement('option'));
                            row.find("[id*=ddlGoodsSubCode]").append(selectOption.val(Result[i].Value).html(Result[i].Text));
                        }
                    },
                    error: function (Result)
                    {
                        alert(Result);
                    }
                });
            }
            catch (e)
            {
                alert(e);
            }
        });
    });
</script>

 

Posted 16 days ago

Please check the url. Its not valid.

Forward slash is missing.