Daftar dan Belajar Sekarang!

Function btn apply pada form "data tidak ke save dalam database"

foto chandraaditya92
3 Kontribusi 0 Coto
2 bulan yang lalu
Query pada controller :
function apply() {
		
		$rules = $this->validateForm();

		$this->form_validation->set_rules( $rules );

		if( !empty($rules) && $this->form_validation->run()){
			$data =	array(
					'message'	=> 'Ops , The following errors occurred',
					'errors'	=> validation_errors('<li>', '</li>')
					);			
			$this->displayError($data);
		}

			$data = $this->validatePost();
			$ID = $this->model->insertRow($data , $this->input->get_post( 'id' , true ));
			// Input logs
			if( $this->input->get( 'id' , true ) =='')
			{
				$this->inputLogs("New Entry row with ID : $ID  , Has Been Save Successfull");
			} else {
				$this->inputLogs(" ID : $ID  , Has Been Changed Successfull");
			}
			// Redirect after save	
			SiteHelpers::alert('success'," Data has been saved succesfuly !");
			if($this->input->post('submit'))
			{
				redirect( 'laundry_order/add/'.$ID,301);
			} else {
				redirect( 'laundry_order',301);
			}	
	}
Query pada form :
function apply(){
	var optionText = $("#customer_id option:selected").text();
	var datastring = $("#form_order").serialize();
  
	$.ajax({
                url: '<?php echo base_url("laundry_order/ajax_save_order");?>',
				type: "post",
				data: datastring+"&customer="+optionText,
				success: function (response) {
					var data = $.parseJSON(response);
					if (data.s == 'success'){
						window.location = "<?php echo base_url();?>laundry_order/getDataById?id=" +data.d;
					}else{
						alert(data.m);
					}
				},
				error: function(jqXHR, textStatus, errorThrown) {
				console.log(textStatus, errorThrown);
				}
    });
}
  • coba belajar debug pelan pelan, mulai dari backend kamu, pastikan semua nilainya sudah sesuai yang kamu inginkan https://sekolahkoding.com/forum/cara-menampilkan-error-debug-di-php-1552899672 - hilmanski


Login untuk diksusi di forum sekolah koding