ajax 无法 POST /index.html 科尔多瓦

时间:2021-03-30 10:52:04

标签: ajax cordova

DB.connect((err) => {
     if(err){
        throw `error: ${err}`       
     }
     console.log("Database connected successfully");
 });
          <script>
            $.ajax({
      url: "http://localhost/app/connexion.php",
      type: "POST",
      dataType: "json",
      /*contentType: 'application/json',
      data: '{ email: "hajjajihajer24@gmail.com", password : "00000" }',*/
      data: $("#connexionForm").serialize(), 

      success: function(msg){
                              if(msg == "1") {
                                  $("#status").text("Login Success..!");
                               
                              }
                              },
      error: function(jqXHR, textStatus, errorThrown) {
          console.log(textStatus + jqXHR.responseText);
      }
  });

我正在使用简单的 REST 调用构建 Cordova 应用程序。

问题是当我使用 POST 进行 AJAX 时,Chrome 在控制台上向我发送:“XMLHttpRequest 无法加载 http://localhost/app/connexion。预检响应具有无效的 HTTP 状态代码 405”。 并返回无法发布/index.html 但是,如果我使用 GET 进行 AJAX 调用(基本上是从数据库返回一个值),事情就会像魅力一样发挥作用。

0 个答案:

没有答案