c# - Issue with getJson in asp.net mvc4 -
i have asp.net mvc 4 project in client side need send part data via ajax , display returned result. have in response []. i'm debugging , i'm sure have not null list<> collection. know mistake?
<script> $(document).ready(function() { $(function() { $('#navigation a').click(function () { $.getjson('/home/getjoblist', function (data) { $("#headerjobrow").text(""); $.each(data, function (i, job) { $("#headerjobrow").append("<li>" + job.title + "</li>"); }); }); }); }); }); </script> [httpget] public jsonresult getjoblist() { int roll = 0; if (request.cookies["cityid"] != null) { roll = convert.toint32(request.cookies["cityid"].value); } iqueryable<jobsdb_jobpostings> jobs = roll > 1 ? _jobpostrepo.getall().where(x => x.cityid == roll).orderbydescending(x => x.postingid) : _jobpostrepo.getall().orderbydescending(x => x.postingid); return json(jobs.tolist(), jsonrequestbehavior.allowget); }
why u nesting ready
handler
$( document ).ready(function() { // handler .ready() called. });
is equivalent to
$(function() { // handler .ready() called. });
Comments
Post a Comment