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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:56:07+00:00 2026-06-15T23:56:07+00:00

why doesn’t my ajax execute? I have checked the controller and the model and

  • 0

why doesn’t my ajax execute? I have checked the controller and the model and they were fine.
The problem is the main ajax which is :

function updateTable()  {
var count = document.getElementsByName('chk[]').length;
var academic = document.getElementById('cb_AcademicYear').value;
var acyear = academic.substr(0,4);
var sem = "SE00"+academic.substr(5);
var yearlevel = document.getElementById('cb_Yearlevel').value;
var acstart = "";
var acend = "";
var atstart = "";
var atend = "";
var status = "";
var successCount =0;
var ele = "";
var data = "";
for (i=0;i<count;i++)
{
    if(document.getElementById('chk_'+i).checked)
    {
        ele = i+"[]";
        acstart = document.getElementById('acstart_'+i).value;

        acend = document.getElementById('acend_'+i).value;

        atstart = document.getElementById('atstart_'+i).value;

        atend = document.getElementById('atend_'+i).value;

        status = document.getElementById('cmb_'+i).value;

        var postData = {
            'acyear' : acyear,
            'sem' : sem,
            'yearlevel' : yearlevel,
            'acstart' : acstart,
            'acend' : acend,
            'atstart' : atstart,
            'atend' : atend,
            'status' : status
        };

        $.ajax({
        url: '<?php echo base_url()?>academicCalendar_entry/update', 
        data: postData ,
        type: 'POST',
        success: function (data){
            successCount++;
        }
        });
    }
}
alert("Successfully inserted ("+successCount+") data(s) including: "+count+ele+acstart+acend+atstart+atend+status+"\n"+academic+acyear+sem+yearlevel+"\n\nand this is the link for the jquery : <?php echo base_url()?>academicCalendar_entry/update/");

}

I put the postdata as an array, which suppose to be fine. But I didn’t put it as a json datatype. Do I have to put it as a json datatype? In the error console, I see no error message but it still didn’t execute to the database.

can anyone solve this??

Edited on 12 Dec 2012 :
this is my update() function in my controller :

function update()
    {
        $academic_year = $_POST['acyear'];  //trim($this->input->post('acyear'));
        $semester = $_POST['sem'];          //trim($this->input->post('sem'));
        $yearlevel = $_POST['yearlevel'];       //trim($this->input->post('yearlevel'));
        $acstart = $_POST['acstart'];           //trim($this->input->post('acstart'));
        $acend = $_POST['acend'];               //trim($this->input->post('acend'));
        $atstart = $_POST['atstart'];           //trim($this->input->post('atstart'));
        $atend = $_POST['atend'];               //trim($this->input->post('atend'));
        $status = $_POST['status'];         //trim($this->input->post('status'));
        $auditname = "Admin";
        $auditactivity = "U";
        $audittime = date("Y-m-d");
        $this->load->model('calendar_Model','cm');
        $this->cm->updateAcademicEntry($academic_year,$semester,$yearlevel,$acstart,$acend,$atstart,$atend,$status,$auditname, $auditactivity, $audittime);
        return true;
    }

I have tried using the $this->input->post, with trim, and with $_POST(), but none of them solve it.

And this is where I put the updateTable() func :

<input type="submit" name="btn_save" id="btn_save" value="Save" onclick="updateTable()"/>

This is my updateAcademicEntry() func in Model :

function updateAcademicEntry($academic_year,$semester,$yearlevel,$acstart,$acend,$atstart,$atend,$status,$auditname, $auditactivity, $audittime)
{
    $data = array(
                'Tahun_Akademik'=>$academic_year,
                'Tanggal_Mulai_Akademik'=>$acstart,
                'Tanggal_Akhir_Akademik'=>$acend,
                'Tanggal_Mulai_Kehadiran'=>$atstart,
                'Tanggal_Akhir_Kehadiran'=>$atend,
                'Status'=>$status,
                'NamaAudit'=>$auditname,
                'AktivitasAudit'=>$auditactivity,
                'TanggalAudit'=>$audittime,
                'ID_Semester'=>$semester,
                'ID_Level_Year'=>$yearLevel
                );
    $this->db
            ->where('Tahun_Akademik',$academic_year)
            ->where('ID_Level_Year',$yearLevel)
            ->where('ID_Semester',$semester)
            ->update('trkalenderakademik',$data);
}
  • 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-15T23:56:08+00:00Added an answer on June 15, 2026 at 11:56 pm

    There are 2 possible problems:

    1. There is an error in your controller. In which case you have to change it.

    2. You mean to add the alert in the callback. Currently the alert runs if the function works or not.
      Also since the ajax runs async to the alert the alert will not have update value of successcount

      $.ajax({
        url: '<?php echo base_url()?>academicCalendar_entry/update', 
        data: postData ,
        type: 'POST',
        success: function (data){
           successCount++;
           alert("Successfully inserted ("+successCount+") data(s) including: "+count+ele+acstart+acend+atstart+atend+status+"\n"+academic+acyear+sem+yearlevel+"\n\nand this is the link for the jquery : <?php echo base_url()?>academicCalendar_entry/update/");`
      
         }
      });`
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doesn't value have to return toString() to be able to call value.toString()? When do
Why doesn't position:absolute always mean absolute to the document? When you have a divB,
Why doesn't this work? I have bypassed this before but i can't remember how
Doesn't configuring WCF in code require more coupling with the model and service libraries?
MySQL doesn't seem to have deffering constraints until the end of a transaction implemented
Why doesn't sockets/remoting have the ability to work smoothly when disconnected and reconnected repeatedly?
I have an autohotkey script which looks up a word in a bilingual dictionary
This doesn't give the full URL, which breaks as it's in a mailer <%=
UITableViewController doesn't scroll automatically anymore? When you have a text field inside a UITableViewController
Why doesn't the following style work? I have in other places the exact same

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.