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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:21:34+00:00 2026-06-08T01:21:34+00:00

I am trying to submit video url and return an embedded code without page

  • 0

I am trying to submit video url and return an embedded code without page refresh or button. I have js function that will grab the value of the input box. The problem is that, the function will not submit the form that will echo the embedded code. How can i make the form submit without a button click or refresh so it can echo the php code?

EXAMPLE

JS for submitting without refresh:

            <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. What you want to do 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', form, function(data){ 


                       });
                  });

            });
            </script>

HTML

<html>
    <form  method="post" id="ytVideo" action="">
    Youtube URL:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="video-input1" type="text" value="<?php $url ?>" name="yurl">   
    </form>
</html>

PHP

  <?php

    if($_POST)
    {
        $url     = $_POST['yurl'];


        function getYoutubeVideoID($url) {
            $formatted_url = preg_replace('~https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be/| youtube\.com\S*[^\w\-\s])([\w\-]{11})      
                    (?=[^\w\-]|$)(?![?=&+%\w]*(?:[\'"][^<>]*>| </a>))[?=&+%\w-]*~ix','http://www.youtube.com/watch?v=$1',$url);
            return $formatted_url;
        }
        $formatted_url = getYoutubeVideoID($url);
        $parsed_url = parse_url($formatted_url);




        parse_str($parsed_url['query'], $parsed_query_string);
        $v = $parsed_query_string['v'];

        $hth        = 300; //$_POST['yheight'];
        $wdth       = 500; //$_POST['ywidth'];


//Iframe code

echo htmlentities ('<iframe src="http://www.youtube.com/embed/'.$v.'" frameborder="0" width="'.$wdth.'" height="'.$hth.'"></iframe>');

}
?>
  • 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-08T01:21:36+00:00Added an answer on June 8, 2026 at 1:21 am

    Try adding a return false at the end of your .submit() handler:

    $('#ytVideo').submit(function(e){
       ...
       $.post(..., function() {
    
       });
    
       return false; // add this
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to submit a form with AJAX through jQuery: $('.submit input').click(function() {return false;});
I'm trying to create a form that will handle video file uploads from the
i'm trying to submit my Ajax form using jQuery. However calling the submit() function
I'm trying to submit a form on an .asp page but Mechanize does not
I'm trying to submit a form witch sends an email: JS var that =
I'm trying to submit a form with mechanize but have run into an error
I am trying to submit a form using jQuery's .ajax() function. It seems like
I am trying to submit a form by using jquery automatically after page load
I'm trying to submit a page onto itself by using php echo $_SERVER['PHP_SELF']; but
I'm trying to implement a flex app that will be able to record a

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.