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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:45:46+00:00 2026-05-22T16:45:46+00:00

from File upload with jQuery and CodeIgniter (But no page refresh) @cbrandolino suggest me

  • 0

from File upload with jQuery and CodeIgniter (But no page refresh)

@cbrandolino suggest me to use jQuery form plugin to solve my problem. It was working well except for one issue, the callbackfunction isn’t fire as I expected.

Here’s my modified code
++ Javascript ++

$('#send_button').live('click', function(){
    var options = {
        url: 'formHandle/add',
        success: function(){
            alert('something');
        }
        //I tried both function() or function(data) 
        //or a function created outside $(document).ready()
        //None of them works
    };
    $('#new_entry_form').ajaxSubmit(options);
})

++ Controller ++

function add(){
    $array = array(
        'title' => $this->input->post('title'),
        'description' => $this->input->post('description'),
        'content' => $this->input->post('content'),
        'start' => $this->input->post('start'),
        'due' => $this->input->post('due'),
        'price' => $this->input->post('price'),
        'promotion_price' => $this->input->post('promotion_price'),
        'website' => $this->input->post('website'),
        'author' => $this->input->post('author'),
    );

    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['overwrite'] = false;
    $config['remove_spaces'] = true;
    $config['encrypt_name'] = true;

    $this->load->library('upload', $config);
    if($this->upload->do_upload('picture')){
        $array['picture'] = $this->upload->file_name;
        $this->load->model('entry_model');
        $this->entry_model->insertEntry($array);
        echo 'true'; 
        //I tried $this->load->view, echo or return
        //none of them works
    }else{
        echo 'false';
    }
}

The file upload was working, the file was uploaded to the specific folder.
The data insertion was working, the data was inserted to the database as expected.
The only problem I have is the callback function.

Do you have any idea how to fix this? I need to show the result of data insertion.

Update:
Adding return false help me nothing. Still not working

  • 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-22T16:45:47+00:00Added an answer on May 22, 2026 at 4:45 pm

    write callback function in option, clearly written here

    $(document).ready(function() { 
    var options = { 
        target:        '#output2',   
    
        success:       showResponse  // post-submit callback 
     }; 
    
    // bind to the form's submit event 
    $('#myForm2').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
    
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
    }); 
    
    function showResponse(responseText, statusText, xhr, $form)  { 
        // for normal html responses, the first argument to the success callback 
        // is the XMLHttpRequest object's responseText property 
    
        // if the ajaxSubmit method was passed an Options Object with the dataType 
        // property set to 'xml' then the first argument to the success callback 
        // is the XMLHttpRequest object's responseXML property 
    
        // if the ajaxSubmit method was passed an Options Object with the dataType 
        // property set to 'json' then the first argument to the success callback 
        // is the json data object returned by the server 
    
        alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
            '\n\nThe output div should have already been updated with the responseText.'); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery file upload plugin . I don't use the UI part, only
I'm using the demo page provided with the jQuery File Upload version 5.6 from
I am using jquery form plugin for file upload . my question is how
I'm using the jQuery plugin ajaxForm to submit a file upload form via AJAX.
I'm using the script from http://webdeveloperplus.com/jquery/ajax-multiple-file-upload-form-using-jquery/ I modified the onComplete to add a link
I have file upload using jquery form plugin as $(function() { $(#Form).ajaxForm({ iframe: true,
I'm trying to use this script from Github at https://github.com/blueimp/jQuery-File-Upload The script has js
I need to upload a file from the client to an asp.net page. The
I'm trying to extend a form and add an upload file field from within
I am getting strange behaviour when trying to upload files, using jQuery multi-file plugin,

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.