Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:19:08+00:00 2026-06-17T19:19:08+00:00

I have an action link in a form that needs to be updated with

  • 0

I have an action link in a form that needs to be updated with a token every minute. I get the new url/token from an api call when the user clicks on the submit button. I’m using something like this

 <form id="somelink" action="http://some.external.url/" target="_blank" />

 $('#somebutton').click(function(e) {
      e.preventDefault();
      var url = '/apicall?id=' + $('#someid').val();                  
      $.post(url, function(data) {
           $('#somelink').attr('action', data);
           $('#somelink').submit();

problem is, using js/jQuery when it submits it opens in a new window without the typical menu and buttons in the browser and it’s the size of a popup window.

Without the jQuery if I just clicked on the button it’ll open in a new tab.

How can I accomplish this with jQuery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:19:09+00:00Added an answer on June 17, 2026 at 7:19 pm

    Instead of catching the click event, try catching the submit event of the form and in case you find any error you can use event.preventDefault();
    Update
    Here i tested with this code and it’s working fine,

    <!doctype html />
    <html>
      <head>        
        <title></title>
        <script type="text/javascript" src="jquery.js"/></script>
    </head>
    <body>
      <form action='http://someSite.com' id='somelink' target='_blank'>
        <input type='text' name='lol' id='lol'/>
        <input type='submit'/>
      </form>
      <script type="text/javascript"/>
          $('#somelink').on('submit',function(e) {
              if($('#lol').val() == "poop"){ //Sample error check
                  e.preventDefault();
                  alert($('#lol').val());
              }
          });
      </script>
    </body>
    </html>
    

    What this does is, if you enter “poop” it does not submit the form, for anything else it submits the form to new tab. Hope this helps 🙂
    Update:
    Regarding your comment, if in case of error you want to open some other tab, then replace e.preventDefault() with $(this).attr({"action":"http://www.someothersite.com"}); . Hope this helps 🙂
    Update:
    If you want to open a tab asynchronously, then you would have a hard time, this is the closest it can get.
    HTML Part

    <form id="someForm" action="about:blank" target="newStuff" />
    <input type="submit" value="12345" id="someid" />
    

    Javascript Part

    $(document).ready(function() {
     $('#someForm').submit(function(e) {
        $.ajax({
            url: 'http://search.twitter.com/search.json?',
            dataType: 'jsonp',
            success: function(data) {
                if (data != "") {     
                    var link = "http://www.google.com/";
                    window.open(link,'newStuff'); //open's link in newly opened tab!
                }
            }
        });
     });
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this link: <a href=<?php echo $this->url(array('controller'=>'index','action'=>'form'),NULL,TRUE);?>> Form </a> With this I get
i have a link <a id=DownloadLink href='controller/action' target=_blank>Download File</a> that has to open a
I have an action filter which i got from the below link http://blog.wekeroad.com/blog/aspnet-mvc-securing-your-controller-actions/ there
Basically put, I have an action that saves a form to a database, then
I have a 'form' that generates a url for a user via javascript. This
I have a action link on my MVC3 razor view. Which have a action
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have this link @Ajax.ActionLink(comment, CreateDebateComment, new { id = Model.DebateID}, new AjaxOptions {
I have an action like so: @Html.ActionLink(dinner.Title, Details, new { id=dinner.DinnerID }) and a
I have some code that when a user clicks on a link Add Comment,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.