I have a simple set code to bring a set of data that is triggered from the drop down
This script is:
function () {$ ('# provider ID'). Change (function () {$ .ajax ({url: '/ servicesDisplay / index', type: 'go', data: {ID: $ (this) .attr ('value')}, success: work (results) {// AJAX request succeeded and results will be included in the variable // part of the action back to the HTML / we inject it into the div: $ ('# serLocations'). Html (results);}});}); This is the controller:
the public performance index (string id) {int prid = int32.Parse (id.Substring (0, (id length -1))); String value = id.Substring ((id.Length-1), 1) .ostring (); System.Data.Objects.ObjectResult & LT; GetProviderServiceAddress_Result & gt; ProList = theEntities.getProviderServiceAddress (pride); & Lt; GetProviderServiceAddress_Result & gt; ObjList = proList.ToList (); Selection list provider list = new selection list (objList, "address id", "address1"); //ViewBag.providerList = Provider list; Back partial view ("service performance / index", provider list); } This view is: @ Models OCS_CS.Models.servicesDisplay & lt; Div & gt; @ Html.DropDownList (model = & gt; Model. ServiceAdderssID, (IEnumerable & lt; SelectListItem & gt;) model) & lt; / Div & gt; When the value of the drop down down in the value kills the app controller but it highlights the drop down in a light red color and the view is never displayed.
Try this short version Jquery uses the load method. $ (function () {$ ('# provider ID'). Change (function () {$ ('# serLocations') .load ("@ Url.Action" ("index "," Services Decis ") ID =" + $ (this) .val ());});}); If you want to avoid caching the result, To avoid, you can send a unique timestamp with the query string.
$ ('# serlations') .load ("@ Url.Action" ("Index", "Services Decis" ) ID = "+ $ (this) .val () +" & amp; t = "+ $. Now ());
No comments:
Post a Comment