Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2016
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    go to an <a> link in query.

    Hello, I have a snippet like this, this is I code I found to submit form data with Ajax, which works very well.
    Code:
    		.done(function(data){
    			$('#inputs').fadeOut('fast', function(){
    				$('#inputs').fadeIn('fast').html(data);
    			});
    		})
    However, after the data is submitted, I would like it to simulate the another action as if the user click on an <a> link but I am not sure how it can be done.
    I am thinking something similar to this:
    Code:
    		.done(function(data){
    			$('#inputs').fadeOut('fast', function(){
    				$('#inputs').fadeIn('fast').html(data);
    				$('<a....></a>').click();    /* Something like this go to the desired link here, but HOW? */
    			});
    		})
    Any suggestion? Thanks.

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    West Des Moines, Iowa
    Posts
    8,197
    Thanks
    38
    Thanked 1,092 Times in 1,088 Posts
    Better to use:
    location.href='http://www.example.com';
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  3. #3
    New to the CF scene
    Join Date
    May 2019
    Location
    Ahmedabad
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi rich1812,
    Try using any one among the following:
    (1)
    Code:
    window.location.href = "url";
    (2)
    Code:
     window.location.href = '@Url.Action("Action", "Controller")';
    (3)
    Code:
    window.location.replace("url");
    (4)
    Code:
    $(location).attr('href',url);

  4. #4
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    West Des Moines, Iowa
    Posts
    8,197
    Thanks
    38
    Thanked 1,092 Times in 1,088 Posts
    Hi Sherin Mathew,
    You do realize this question was asked and answered in Jan. 2017?
    The dates are top left of the posts, in the light gray area.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •