JQuery get function: How to open url.action result in same window

I am using the JQuery get function to load a web page from the controller using a Url.Action command.  The command executes correctly but it always opens the web page in a new window whereas I need it to open in the current window.    I believe I have to set the 'target' attribute to '_self'.  How do I modify the code below to do this?

 $.get('@Url.Action("Index", "Control")' function (data) {
            //do something
            })
ccravenbartleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
The $.get does not work like that - what I suspect is happening is that you are performing a $.get on a full page and then adding that to the DOM. The requested page has its own <html> and <body> tags which is confusing the browser.
Consider this code
HTML
    <a href="t1164.html">This page</a><br/>
    <a href="t1164.partial.html">Partial page</a>
    <div id="response"></div>

Open in new window

And this jQuery
<script>
$(function() {
  $('a').click(function(e) {
    e.preventDefault();
    $.get($(this).attr('href'), function(resp) {
      $('#response').html(resp);
    });
  });
});
</script>

Open in new window

Partial page
<div>
  <p>This is a partial page</a>
</div>

Open in new window

Clicking the first link loads the parent page and adds it to the response <div> the second loads a partial page. Working sample here demonstrates the concept. Click each link to see the different result.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.