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 8234139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:22:39+00:00 2026-06-07T18:22:39+00:00

I am currently using js function to submit data without page refresh or button

  • 0

I am currently using js function to submit data without page refresh or button click. The input field is inside tab #2 that executes the js once the user stops typing. The problem is that the js is making the page refresh thus taking me back to tab#1. How can I prevent the page from refreshing? I thought i had included the necessary code in the JS function to stop this. EXAMPLE

<script>
$(document).ready(function() {
    var timer;
        $('#video-input1').on('keyup', function() {
            var value = this.value;

            clearTimeout(timer);

            timer = setTimeout(function() {

                //do your submit here
                $("#ytVideo").submit()


                //alert('submitted:' + value);
            }, 2000);
        });

    //submit definition once submit is executed
    $('#ytVideo').submit(function(e){
        e.preventDefault(); //prevent page refresh
        var form = $('#ytVideo').serialize();

        //submit.php is the page where you submit your form
        $.post('index.php#tab-2', form, function(data){ 
            var x = $(data);
            $("body").html(x);
        });
        return false;
    });
    return false;                                                         

});
</script>
  • 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-07T18:22:42+00:00Added an answer on June 7, 2026 at 6:22 pm

    try changing this line

    //do your submit here
    $("#ytVideo").submit()
    

    to

    $("#ytVideo").trigger("submit");
    

    i believe the problem is that you define what submit should do after the form has been submitted this causes the page to reload.
    Edited
    try this change

    $('#ytVideo').submit(function(event){
            event.preventDefault(); //prevent page refresh
            event.stopPropagation(); //+
            var form = $('#ytVideo').serialize();
    
            //submit.php is the page where you submit your form
            $.post('index.php#tab-2', form, function(data){ 
                var x = $(data);
                $("body").html(x);
            });
            //- return false;
        });
        //- return false;  
    

    made some changes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using Ajax to submit an input field without a page refresh
I am currently using Ajax/JS to submit a form without a page refresh or
I'm working on a jQuery function that forwards form data to page without interfering
I am using a function that will submit with ajax and without the help
I am currently using a function in my app's didFinishLaunchingWithOptions that retrieves a file,
I am currently using the following code to update form data before submission. $('.countyx').change(function(){
I'm using the JQuery AJAX function to deliver data to a PHP doc. Currently,
I have a basic form that I would like to submit using ajax, without
I'm currently using the toprettyxml() function of the xml.dom module in a Python script
Here is the code I'm currently using: $.ajax({ success: function(){ $('.post_container').append('test <br />'); }

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.