Welcome Guest, Not a member yet? Register   Sign In
facing problems with inserting data
#11

(This post was last modified: 02-12-2018, 02:32 PM by dave friend.)

You mean the "Send Now" button - right?

I don't see the "savesms()" method anywhere. While looking for it I notice that you have a controller and model that are both named "sms". You probably shouldn't do that. Perhaps name the model "sms_model".

The next problem of note is with using sms_form() with the $.post(... call. $.post(... expects data to be returned by the server but you make a redirect() instead. That's wrong. Echo some data in reply instead. Here's one way but it is presented without knowledge of what happens in "savesms()" so it's maybe not the best solution.

PHP Code:
public function sms_form()
    {
        
$save = array(
            
'sender'           => $this->input->post('sender'),
            
'recepients'       => $this->input->post('recepients'),
            
'body'             => $this->input->post('body'),
            
'sendscheduletime' => $this->input->post('sendscheduletime'),
        );
        
//if savesms() returns false when saving fails then use
        
echo $this->sms->savesms($save) ? "Success" "Fail";
    } 

Looking more closely at your <form> I cannot find an <input> for either 'sender' or 'sendscheduletime'. So your $save array will have NULL values for those two items.

Just to make sure the "Send Now" button 'click' event is being handled do this test.

Code:
$("#SendSMS").click(function () {
    event.preventDefault();
    alert('Send SMS Clicked');
   // var postData = $('#SendSMSForm').serializeArray();

   // $.post("<?php echo base_url('sms/sms_form') ?>", postData)
           // .done(function (data) {
             //   alert("Data Loaded: " + data);
          //  });
});
Reply


Messages In This Thread
facing problems with inserting data - by CharlesK - 02-10-2018, 12:57 AM
RE: facing problems with inserting data - by dave friend - 02-12-2018, 08:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB