Error: Preflight request returned a 405 HTTP status code when querying Ionic + CI backend

I am currently working on my first app using ionic with a codeigniter backend. However, I am encountering the "Response for preflight has invalid HTTP status code 405" issue in ionic + CI backend. Can anyone help me solve this problem?

This is 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
  });

});
};

Here is 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);

    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take in modifying my existing code to use jQuery to set my div to a minimum height rather than a fixed height?

Could someone assist me in adjusting my div to have a min-height instead of a regular height? Whenever I click on the "Learn more" button, it extends past my div because the function is designed to set a specific height rather than an equal height. $.fn.e ...

Locate the position of the cursor within a rectangular shape

I'm struggling to determine the location of a cursor within a rectangle, specifically which part (one of 4 triangles) it is in. This visual representation helps me grasp it better than any explanation I can come up with :s Working in javascript (whe ...

Rails javascript not triggering even after the page is loaded with `page:load`

My experience with using Stripe in Rails has been smooth, except for some issues with Ajax calls not working properly after page refresh. I suspect this might be related to Turbolinks as the 'ready page:load' event doesn't behave as expected ...

Reply in Loopback on remote method beforeRemote hook is to be sent

In my application, I am utilizing loopback v3. The specific use case I am tackling involves validating the presence of a token in the request header. If the token is invalid, I need to send an appropriate message in a standardized format. My approach has b ...

Issue with jQuery animation delay functionality experiencing issues specifically in Google Chrome browser

While browsing through similar questions, I couldn't find one quite like mine where the effect was working on one window but not on a subsequent one. I'm using jQuery library version 3.4.1. The code has been tested and is functioning as expected ...

Is it permissible to access an iframe directly by its name?

I recently came across some JavaScript code that directly accesses an iframe by its name, without using getElementById() or any other method. Surprisingly, this code seems to be functioning properly in browsers like Chrome, Firefox, IE10, and Safari for Wi ...

When attempting to assign a 'string' type to the @Input property, I am receiving an error stating that it is not assignable to the 'PostCard Layout' type

Encountering an issue The error message 'Type 'string' is not assignable to type 'PostCard Layout'' is being displayed A parent component named page-blog.component.html is responsible for defining the class styles and passi ...

Can you identify this numerical category?

Can you identify this number type? console.log(0100); // output 64 console.log(050); // output 40 console.log(010); // output 8 In a hexadecimal system, it would be: 0100 = 256 050 = 80 010 = 16 ...

Tips for transferring variables as arguments in javascript

Currently, I am immersed in a test project aimed at expanding my knowledge of web development. Unexpectedly, I have encountered an issue that has left me puzzled on how to proceed. Within this project, there exists a table consisting of 11 cells. While 9 ...

JSDoc encounters issues when processing *.js files that are produced from *.ts files

I am currently working on creating documentation for a straightforward typescript class: export class Address { /** * @param street { string } - excluding building number * @param city { string } - abbreviations like "LA" are acceptable ...

Implementing one-time binding and optimizing 'track by' in ng-repeat loop

Our web application utilizes ngRepeat to showcase a list of items. Although the array and its objects remain constant, the user can modify the values of these objects. We assign a unique trackId to each item, which is regularly updated whenever the item&a ...

Ways to transfer object from controller to directive in angularJS without relying on $scope

Check out my Plunker project: http://plnkr.co/edit/j7BeL72lwHISCIlwuAez?p=preview The current implementation uses $scope to pass data, but I am interested in switching to a model approach and replacing $scope.data in MainController with this.data. Initia ...

Steps to submit a JavaScript-generated output as the value in a form input field

I'm facing an issue that seems basic, but I can't seem to figure it out. I'm trying to create a binary string representing the 12 months of the year using 12 checkboxes: const checkboxes = [...document.querySelectorAll('input[type=check ...

Unveiling the essence of AngularJS directives

Is there a proper way to abstract a directive in AngularJS? Consider the following basic example: http://plnkr.co/edit/h5HXEe?p=info var app = angular.module('TestApp', []); app.controller('testCtrl', function($scope) { this.save = ...

Angular UI-Grid encountering difficulties in rendering secure HTML content

I'm having trouble displaying server-generated HTML in UI-Grid. Specifically, I want to show HTML content in my column header tooltips, but no matter what I try, the HTML is always encoded. Here's an example to illustrate the issue: var app = an ...

Ways to retrieve the chosen option from a dropdown menu within an AngularJS controller

I have a drop down (combo box) in my application that is populated with values from a JSON array object. Can someone please explain how to retrieve the selected value from the drop down in an AngularJS controller? Appreciate the help. ...

update confirmed data from a record

I am facing a unique challenge, where I have an edit form that updates a record in a table. One of the fields, let's say username, needs to be unique. To validate this, I am using the jQuery validation plugin along with the remote method as shown belo ...

Merging a variable and its corresponding value in JavaScript

I am attempting to achieve a similar functionality in Angular javascript (with simplified code): var modelName = "date"; if (attrs.hasOwnProperty('today')) { scope.modelName = new Date(); } In the scenario above, my intention is for scope.m ...

The JSON format in ASP.Net Core MVC does not have designated data fields

I am currently facing an issue with my JavaScript code related to cascading dropdowns. The setup involves having one dropdown for selecting a car brand and another dropdown for choosing a specific model under that brand. The functionality should work in su ...

What is the best way to create a JavaScript button that can be clicked to increase a variable by 1?

I am curious to know how you can create a button that appears on an empty HTML canvas and, when clicked, adds +1 to a variable. I am working on this JavaScript code within an HTML text file which will later be saved as an HTML file. Please ensure that th ...