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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:26:49+00:00 2026-05-30T03:26:49+00:00

I am using ajax to update the db with a new folder but it

  • 0

I am using ajax to update the db with a new folder but it refreshes the page after ENTER is hit.
on my form I have onkeypress="if(event.keyCode==13) savefolder();"
here is the javascript code that I have: what it does basically is after you hit enter it calls the function savefolder, savefolder then sends a request through ajax to add the folder to the db. Issue is it refreshes the page… I want it to stay on the same page.
any suggestions? Thank you

<script>


 function savefolder() {

var foldername= jQuery('#foldername').val(),
    foldercolor= jQuery('#foldercolor').val();
//  ajax request to add the folder
            jQuery.ajax({   
                type: 'get',
                url: 'addfolder.php',
                data: 'foldername=' + foldername + '&foldercolor=' + foldercolor,       
                beforeSend: function() { alert('beforesend');}, 
                success: function() {alert('success');}
            });

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-05-30T03:26:50+00:00Added an answer on May 30, 2026 at 3:26 am

    This is working:

    <form>
        <input type="submit" value="Enter">
        <input type="text" value="" placeholder="search">
    </form>
    
    function savefolder() {
        var foldername= jQuery('#foldername').val(),
            foldercolor= jQuery('#foldercolor').val();
    
        jQuery.ajax({   
            type: 'get',
            url: '/echo/html/',
            //data: 'ajax=1&delete=' + koo,       
            beforeSend: function() {
                //fe('#r'+koo).slideToggle("slow");
            },
            success: function() {
                $('form').append('<p>Append after success.</p>');
            }
        });
    
        return false;
    }
    
    jQuery(document).ready(function() {
        $('form').submit(savefolder);
    });
    

    http://jsfiddle.net/TFRA8/

    You need to check to see if you’re having any errors during processing (Firebug or Chrome Console can help). As it stands, your code is not well-formed, as the $(document).ready() is never closed in the code you included in the question.

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

Sidebar

Related Questions

I have a simple form created using Ajax.BeginForm : <% using (Ajax.BeginForm(Update, Description, new
I have an Ajax Form that looks like this: <% using (Ajax.BeginForm(Update, new AjaxOptions
I'm using an Ajax update panel and have recently added ASP.NET tracing code to
Currently, I am using an with ajax to update my mysql. Now, I have
I have a the following code @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = update_panel, Url
I have the following code in my view: <% using (Ajax.BeginForm(JsonCreate, new AjaxOptions {
I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
I'm using an AJAX form to update an item to the database. When it
I am reloading partial using ajax this way: new Ajax.PeriodicalUpdater('content', '/shouts/update.js', { method: 'get',
I am trying to submit a form using Ajax.Updater and have the result of

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.