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

  • Home
  • SEARCH
  • 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 8273407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:29:02+00:00 2026-06-08T07:29:02+00:00

I am using a function that will submit with ajax and without the help

  • 0

I am using a function that will submit with ajax and without the help of a button click. But I am currently undergoing two issues which with trial and error haven’t found plausible solutions:

First is there any way I can disable the enter button click(this causes the whole page to refresh)?

JSFIDDLE basic example in how the JS function works

Second, It feels like I am going the roundabout way to display what has been posted. How can I change this part of the function $('#special').html('<p>' + $('#resultval', result).html() + '</p>'); to have it POST just inside a div called #special without the need of span or <p> #resultval?

Everytime i echo through php I have to do set it like this to display a result: <div id="special"><span id="resultval">This is the result.</span></div>

<script>
    $(document).ready(function() {
     var timer = null; 
     var dataString;   
     function submitForm(){
       $.ajax({ type: "POST",
                url: "posting.php",
                data: dataString,
                success: function(result){

                   $('#special').html('<p>' +  $('#resultval', result).html() + '</p>');

                }

       });
       return false;
     }
     $('#ytinput').on('keyup', function() {
        clearTimeout(timer);
        timer = setTimeout(submitForm, 050);
        var name = $("#ytinput").val();
        dataString = 'name='+ name;
     });
     }); 

</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-08T07:29:03+00:00Added an answer on June 8, 2026 at 7:29 am
    $(document).ready(function() {
     var timer = null; 
     var dataString;   
     function submitForm(event){// the function call on click or on submit onclick=submitForm(event);
    
        event.preventDefault(); //to prevent enter key
       $.ajax({ type: "POST",
                url: "posting.php",
                data: dataString,
                success: function(result){
    
                   $('#special').text(result); //you can use text() or html() only
    
                }
    
       });
       return false;
     }
     $('#ytinput').on('keyup', function() {
        clearTimeout(timer);
        timer = setTimeout(submitForm, 050);
        var name = $("#ytinput").val();
        dataString = 'name='+ name;
     });
     }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following function. Whenever i call it that time it will increase
Here is the function that i am using: $('.urlz').click(function (event) { event.preventDefault(); var url
I have a dynamically generated form that I would like to submit using Ajax.
I have set up an submit box using ajax function and when success, I
I am using php/ajax to submit a form without page refresh. Here are my
I am using this function (that I found on this forum) to calculate the
Hi am using this function that works by a single ID ( 52000121 )
I'm using a function that uploads an image, takes the stream and resizes it
Here is an (artificial) example of using a function that returns an anonymous struct
I'm using the following function that changes a calendar selection at a set time

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.