Hi experts,
I have a problem in loading a thousand records using ajax it gives me an error "internal Error 500". it can only handled less than 500 records
How can i overcome this problem. Please see my code below thanks in advance.
Webmethod in code Behind
<WebMethod()> _
Public Shared Function BindDataCountryState(ByVal LocationCode As String) As List(Of ListItem)
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
Dim CountryState As New List(Of ListItem)()
Try
Using con
Using cmd As New SqlCommand("usp_GetCountryState")
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@LocationCode", LocationCode)
cmd.Connection = con
con.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
CountryState.Add(New ListItem() With { _
.Value = sdr("Code").ToString(), _
.Text = sdr("Description").ToString() _
})
End While
End Using
Return CountryState
End Using
End Using
Catch ex As Exception
HttpContext.Current.Session("error_message") = ex.Message &"
Return CountryState
Finally
If con IsNot Nothing Then
con.Close()
con.Dispose()
End If
End Try
End FunctionAsp.net Code
var f = document.getElementById("<%=DropDownListPetitionerCountry.ClientID%>");
f.onchange();
var LocationCode = $(f).val();
var parameter = { LocationCode: LocationCode };$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/BindDataCountryState",
data: JSON.stringify(parameter),
dataType: "json",
////data: '{}',
success: function (f) {
var ddlCustomers = $("[id*=DropDownListStateProvince]");$.each(f.d, function () {
ddlCustomers.append($("<option></option>").val(this['Value']).html(this['Text']));
});
},
error: function (result) {
alert("Error " + result.status);
console.log(result.status)
}
});