Tuesday 15 March 2011

jquery - not getting response of partial view with ajax get request on checkbox change event -



jquery - not getting response of partial view with ajax get request on checkbox change event -

i want display records on checkbox alter event.this code:

my view page:

<div> <li> <input name="chk" type="checkbox" value="1"> electronics </li> <li> <input name="chk" type="checkbox" value="2"> construction</li> <li> <input name="chk" type="checkbox" value="1"> hardware</li> <div class="row service-block" id="results"> @html.partial("_searchpartial", model) </div> </div> $("input[type='checkbox']").on('change', function () { var checkboxes = document.getelementsbyname('chk'); var vals = ""; (var = 0, n = checkboxes.length; < n; i++) { if (checkboxes[i].checked) { vals += "," + checkboxes[i].value; } } if (vals) vals = vals.substring(1); $.ajax({ url: "/search/searchworkers", type: "get", datatype: 'json', data: { checkcategoriesid: vals, "flag": "false", "city": "@viewbag.city", "orderby": "@tempdata["orderby"]" }, contenttype: "application/json", success: function (responce) { alert(responce); $("#results").html(responce); }, error:function (xhr, ajaxoptions, thrownerror) { alert("test"); } }) });

this partial view:

@using (ajax.beginform("searchvendors", "search", new ajaxoptions { httpmethod = "get", updatetargetid = "results", onbegin = "beginpaging", onsuccess = "successpaging", onfailure = "failurepaging", })) { ------------ }

this controller:

[httpget] public actionresult searchworkers(string checkcategoriesid,string orderby,string flag,string city, int pageno = 1) { homecoming partialview("_searchpartial", userdetailsmodel.orderbydescending(p => p.createddate).topagedlist(pageno, 1)); }

but not getting response.i geeting alert("test") of error part of jquery.

error:function (xhr, ajaxoptions, thrownerror) { alert("test"); }

can tell whats problem , how resolve it???

jquery asp.net-mvc asp.net-mvc-ajax

No comments:

Post a Comment