Hi All,
In my view I havethe following piece of code:
and then back in the controller:Code:var jSonData = '{ "available" : " ' + availableArray + '", "assigned" : " ' + assignedArray + '", "policyZoneID" : " ' + document.getElementById('policyZoneID').value + '"}'; $.ajax({ type: 'POST', url: window.rootDir + 'FloatingZone/JsonEditFloatingZone', data: jSonData, contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (response) { window.location.href = response.newLocation; }, error: function (xmlHttpRequest, textStatus, errorThrown) { alert(errorThrown); } });
Now as it stands this all works fine and the view correctly does to my desired location.Code:public JsonResult JsonEditFloatingZone(string available, string assigned, int policyZoneID) { string newLocation = string.Concat("../../Edit/", policyZoneID); string apportionmentLocation = string.Concat("/ParentZoneSectionsApportionment/Edit/", policyZoneID); if (FloatingZoneService.EditPolicyZoneFloatingZone(available, assigned, policyZoneID, CurrentUser)) { newLocation = apportionmentLocation; } return new JsonResult { Data = new { newLocation } }; }
I've now been asked to remove the hard coded paths since this may not be the eventual path on deployment and that I should use the conventional MVC way of redirecting. This would be fine if I was performing an ActionResult, but I'm performing a JsonResult, so what's the best way to do this without a total re-design?


Reply With Quote