2017-06-29 2 views
-3

Ich füge die Daten in mysql-Datenbank mit Ajax beim Senden dieses Fehlers wird appaer .Ich mache diese in codeigniter Rahmen. Ich bin neu bie ajax.I ist nicht in der Lage, um herauszufinden, wo falsch .Hier werde, ist mein Code[object Objekt] parsererrorSyntaxError: Unerwartetes Token <in JSON an Position 0

$('#btnSave').text('saving...'); //change button text 
 
      $('#btnSave').attr('disabled', true); //set button disable 
 
      var url; 
 

 
//   if (save_method == 'add') { 
 
      url = "http://[::1]/sms/sms/forms/1"; 
 
//   } else { 
 
//    url = ""; 
 
////   } 
 

 
      var radio=$('#radio').val(); 
 
      var st_id=$('#st_id').val(); 
 
      var branch_type=$('#branch_type').val(); 
 
      bname=$('#bname').val(); 
 
      bcode=$('#bcode').val(); 
 
      baddress=$('#baddress').val(); 
 
      var bcity=$('#bcity').val(); 
 
      var zcode=$('#zcode').val(); 
 
      var bstates=$('#bstates').val(); 
 
      var bcountry=$('#bcountry').val(); 
 
      var bpno=$('#bpno').val(); 
 
      var bemail=$('#bemail').val(); 
 
      var bweb=$('#bweb').val(); 
 
      var Latitude=$('#Latitude').val(); 
 
      var Longtitude=$('#Longtitude').val(); 
 
      var noted=$('#noted').val(); 
 
      var addedby=$('#addedby').val(); 
 

 
      // ajax adding data to database 
 

 

 
      $.ajax({ 
 
       type: 'ajax', 
 
       data: {st_id: st_id, branch_type: branch_type, bname: bname, bcode: bcode, baddress: baddress, 
 
        bcity: bcity, zcode: zcode, bstates: bstates, bcountry: bcountry, bpno: bpno, bemail: bemail, 
 
        bweb: bweb, Latitude: Latitude, Longtitude: Longtitude, noted: noted, addedby: addedby}, 
 
       url: url, 
 
       method: 'post', 
 
       asysc: false, 
 
       dataType: 'json', 
 
       success: function (data) { 
 

 
        if (data.status) //if success close modal and reload ajax table 
 
        { 
 

 
        } 
 
        else { 
 

 
     } 
 
        $('#btnSave').text('Add Record'); //change button text 
 
        $('#btnSave').attr('disabled', false); //set button enable 
 

 

 
       }, 
 
       error: function (jqXHR, textStatus, errorThrown) { 
 
        alert(jqXHR + textStatus + errorThrown); 
 
        $('#btnSave').text('Add Record'); //change button text 
 
        $('#btnSave').attr('disabled', false); //set button enable 
 
// 
 
       } 
 

 
      });
my php code 
 

 
    $submit['sys_t_id']=$this->input->post('st_id'); 
 
       $submit['t_id']=$this->input->post('branch_type'); 
 
       $submit['name']=$this->input->post('bname'); 
 
       $submit['code']=$this->input->post('bcode'); 
 
       $submit['address']=$this->input->post('baddress'); 
 
       $submit['city']=$this->input->post('bcity'); 
 
       $submit['zip']=$this->input->post('zcode'); 
 
       $submit['state']=$this->input->post('bstates'); 
 
       $submit['country']=$this->input->post('bcountry'); 
 
       $submit['contact_no']=$this->input->post('bpno'); 
 
       $submit['email']=$this->input->post('bemail'); 
 
       $submit['web']=$this->input->post('bweb'); 
 
       $submit['latitude']=$this->input->post('Latitude'); 
 
       $submit['longitude']=$this->input->post('Longtitude'); 
 
       $submit['note']=$this->input->post('noted'); 
 
       $submit['addedby']=$this->input->post('addedby'); 
 
       $submit['addedon']=date('Y-m-d:H-m-s'); 
 
       $insert = $this->Smsmodal->insert('branch_info',$submit); 
 
       echo json_encode(array("status" => TRUE)); 
 
      

Antwort

0

Ich glaube, Sie Serverfehler haben! Verwenden Sie console.log (Daten) in Ihrer Erfolgsfunktion, um die Serverausgabe anzuzeigen.

+0

immer noch zeigen Fehler –

+0

Entfernen oder kommentieren "dataType: 'Json'" und schauen Sie auf der Konsole. – drch

Verwandte Themen