in Education by

I am trying develop first app in ionic and with codeigniter backend but facing Response for preflight has invalid HTTP status code 405 problem in ionic + CI backend issue help me to solve this issue. My controller.js: .controller('SingUpCtrl',function($scope,$http){ $scope.signup_cancel = function (){ $state.go('app.login'); }; $scope.signUp=function(){ $scope.data = {}; var postData = { "user_first_name":$scope.data.user_first_name, "user_last_name" :$scope.data.user_last_name, "user_gender" :$scope.data.user_gender, "user_dob" :$scope.data.user_dob, "user_email" :$scope.data.user_email, "user_password" :$scope.data.user_password }; var link = 'http://maghnusideas.com/ionic/index.php/api/places/user'; var header={ "cache-control": "no-cache", "postman-token": "6cfae124-631b-9367-89c7-04c0a12ab489" } $http.post(link, postData,header).then(function (res){ console.log('success'); var json_obj = JSON.stringify(res.data); json_obj = JSON.parse(json_obj); $ionicPopup.alert({ template: json_obj.message }); }); }; My webapi code in codeigniter: public function user_post() { $this->load->library('form_validation'); $this->load->model('Admin_model'); $this->form_validation->set_rules('first_name', 'First Name', 'required'); $this->form_validation->set_rules('last_name', 'Last Name', 'required'); $this->form_validation->set_rules('gender', 'Gender', 'required'); $this->form_validation->set_rules('dob', 'Date of Birth', 'required'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email'); $this->form_validation->set_rules('password', 'Password', 'required'); if($this->form_validation->run()) { $first_name=$this->input->post('first_name'); $last_name=$this->input->post('last_name'); $gender=$this->input->post('gender'); $dob=$this->input->post('dob'); $email=$this->input->post('email'); $password=$this->input->post('password'); } else{ $this->set_response('Failure to add', REST_Controller::HTTP_BAD_REQUEST); } $result=$this->Admin_model->insert('tbl_user',array('user_first_name'=>$first_name,'user_last_name'=>$last_name,'user_gender'=>$gender,'user_dob'=>$dob,'user_email'=>$email,'user_password'=>$password)); if($result) { $this->set_response('User Registered Successfully...!', REST_Controller::HTTP_OK); }else { $this->set_response('Inserted Data not Proper', REST_Controller::HTTP_BAD_REQUEST); } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

Please log in or register to answer this question.

1 Answer

0 votes
by

This error is related to CORS To fix this you can use ionic proxy feature - see http://ionicinaction.com/blog/how-to-fix-cors-issues-revisited/ or here http://blog.ionic.io/handling-cors-issues-in-ionic/

Related questions

0 votes
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
asked Mar 17, 2022 in Education by JackTerrance
...