Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Error-There is already an open DataReader associated with this Command which must be closed first.

$
0
0

Hi

 Below is the code

function FillCity() {
        var stateId = $('#StateId').val();$.ajax({
            url: '/Customer/GetCity',
            type: "GET",
            dataType: "JSON",
            data: { StateId: stateId },
            success: function (cities) {$("#CityId").html(""); // clear before appending new list$.each(cities, function (i, city) {$("#CityId").append($('<option></option>').val(city.CityId).html(city.CityName));
                });
            },
            error: function (xhr, ajaxOptions, thrownError) {$("#errorModalBody").html('Status : ' + xhr.status + ' Error : ' + thrownError);$("#errorModal").modal('show');
            }
        });
    }

Controller
public ActionResult GetCity(int StateId)
        {
            var cities = db.Cities.Where(c => c.StateId == StateId);
            return Json(cities, JsonRequestBehavior.AllowGet);
        }

Thanks


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>