Click here to Skip to main content
15,792,397 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
function onClick(e) {
       var SelectedVal = e.item[0].outerText;

       var urlsearch = "@Url.Content("~/TTSCancel/View2")";
           type: "POST",
           url: urlsearch,
           data: { GetSelectedVal: SelectedVal },

           success: function (result) {
               window.location = result.url;
Thomas Daniels 20-Jan-16 8:13am    
Do you intend to get this URL from the response? If yes, what's the response format? XML, JSON, ...?
Sathish km 20-Jan-16 8:31am    
public ActionResult View2(string GetSelectedVal)
IList<string> split1;
split1 = GetSelectedVal.Split(new[] { '\n' });

ViewBag.Code = split1[0];
ViewBag.Desc = split1[2];

return View();

passing to this..
Thomas Daniels 20-Jan-16 8:34am    
What does View2 look like?
Sathish km 20-Jan-16 8:39am    
Thomas Daniels 20-Jan-16 8:41am    
That doesn't answer my question; I'd like to see your view, not your action method.

"View2" has to return an object in JSON format that has a "url" property. It obviously doesn't but as you haven't posted what "View2" is it's hard to advise why that might be. If you are looking to call an action on a controller then google "jquery call mvc action json" and you'll find examples.
Share this answer
In the comments, you said that you actually just want http://localhost:60972/TTSCancel/View2, which is the absolute URL of the page urlsearch refers to.

You just need to do this:
var absoluteUrl = '@Url.Action("View2", "TTSCancel", null, Context.Request.Scheme)';
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900