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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:29:43+00:00 2026-06-05T16:29:43+00:00

How to create jQuery + ajax form without refresh? This is my controller and

  • 0

How to create jQuery + ajax form without refresh?
This is my controller and views:

http://pastebin.com/GL5xVXFZ

In “clear” PHP I create something like this:

$(document).ready(function(){
    $("form#submit").submit(function() {

    var note = $('#note').attr('value');

        $.ajax({
            type: "POST",
            url: "add.php",
            data: "note="+ note,
            success: function(){
                $('form#submit').hide(function(){$('div.success').fadeIn();});

            }
        });
    return false;
    });
});

in add.php file is INSERT to Database.

  • 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-05T16:29:44+00:00Added an answer on June 5, 2026 at 4:29 pm

    There are more complicated ways of doing this for example detecting an ajax request in your action and then if detected print out a javascript response. The way you would do this is

    JAVASCRIPT

    function postForm(note){
         $.ajax({
          url  : '/controller/action',
          type : 'POST',
          data : 'note='+note,
          success : function(jsn){
            var json = $.parseJSON(jsn);
            if(json.status == 200)
              alert('Completed Successfully');
            else
              alert('Not Completed Successfully');
          },
          error : function(xhr){
            //Debugging
            console.log(xhr);
          }
    
    
         });
       }
    

    PHP

      <?php  
      Class Controller_ControllerName extends Controller_Template{
          public $template = 'template';
    
          public function action_index(){}
    
          public function action_form(){
            $this->auto_render = false; // <-EDITED
            $array = array();
    
            //PROCESSING FORM CODE HERE
    
            if($success){
              $array['status'] = 200;
            }else{
              $array['status'] = 500; 
            }
    
            print json_encode($array);
          }
    
        }
    ?>
    

    this is an example i have done without testing but this surely should be enough for you to work on

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

Sidebar

Related Questions

I'm using the JQuery Form Plugin ( http://jquery.malsup.com/form/ ) to create an Ajax Form.
Hi I have used this tutorial http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/ to create php - jquery - ajax
This is the PHP code im using in conjunction with jQuery .ajax to create
I am trying to create a form that utilizes PHP and Jquery AJAX form
I'm using ExpressionEngine and SafeCracker along with Ajax (plugin: jquery.form.js - http://jquery.malsup.com/form/ ). Best
I'm having problems with understanding how jQuery create headers for ajax post. I have
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
A jQuery AJAX request .post()s data to page.php, which creates $res and var_dump()s it.
I would like to create a comment form based on the jquery validation plugin
I've created a search form for a script in php. Basicaly this form have

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.