Can I pass data via jQuery to ASP.NET MVC controller action and have a view rendered in new browser tab
Can anyone advise if its possible to pass data via jQuery to an ASP.NET MVC controller action and have a view rendered in a new browser tab based on the model data passed to the action method.
My scenario is that I have a jQGrid populated with product info on a page. The user would tick the items in the grid that they would like a label produced for. After they've made their selection they would click a button and I would like (if possible) to render a view which contains a label for each selected item and have the view render in a new browser tab.
All the code to allow the selections and post the relevant data back to the action method is all working fine and I know its easy to use the jQuery $(selector).load() command to populate an element on the current page with the HTML returned from the action.
But is it possible to populate an element on a page in a new browser t开发者_开发知识库ab.
If it is how would I go about it?
Hope this make sense.
You could add target="_blank"
to the form containing the button. The form will post all the necessary data to the controller action and render the results in a new tab.
You can't force the browser to open a new tab through code. The best you can do is open a new window with javascript.
Yes, you can pass data via jQuery to a controller action. You would specify the URL attribute of the jQuery AJAX call as the controller action and use the data attribute to send the necessary items.
As the previous posts have mentioned you cannot explicitly force a new tab to open, but can open a new window. Another option would be to use jQuery UI dialog and have a hidden div on the page that would show as a modal when the user submits.
Hope this provides some insight.
- Jesse
精彩评论