第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

AngularJS POST失?。猴w行前響應(yīng)具有無效的HTTP狀態(tài)代碼404

AngularJS POST失?。猴w行前響應(yīng)具有無效的HTTP狀態(tài)代碼404

嗶嗶one 2019-10-19 14:14:52
我知道有很多這樣的問題,但是我所見的問題都沒有解決。我已經(jīng)使用了至少3個(gè)微框架。所有這些都無法執(zhí)行簡(jiǎn)單的POST,它應(yīng)該返回?cái)?shù)據(jù):angularJS客戶端:var app = angular.module('client', []);app.config(function ($httpProvider) {  //uncommenting the following line makes GET requests fail as well  //$httpProvider.defaults.headers.common['Access-Control-Allow-Headers'] = '*';  delete $httpProvider.defaults.headers.common['X-Requested-With'];});app.controller('MainCtrl', function($scope, $http) {  var baseUrl = 'http://localhost:8080/server.php'  $scope.response = 'Response goes here';  $scope.sendRequest = function() {    $http({      method: 'GET',      url: baseUrl + '/get'    }).then(function successCallback(response) {      $scope.response = response.data.response;    }, function errorCallback(response) { });  };  $scope.sendPost = function() {    $http.post(baseUrl + '/post', {post: 'data from client', withCredentials: true })    .success(function(data, status, headers, config) {      console.log(status);    })    .error(function(data, status, headers, config) {      console.log('FAILED');    });  }});SlimPHP服務(wù)器:<?php    require 'vendor/autoload.php';    $app = new \Slim\Slim();    $app->response()->headers->set('Access-Control-Allow-Headers', 'Content-Type');    $app->response()->headers->set('Content-Type', 'application/json');    $app->response()->headers->set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');    $app->response()->headers->set('Access-Control-Allow-Origin', '*');    $array = ["response" => "Hello World!"];    $app->get('/get', function() use($array) {        $app = \Slim\Slim::getInstance();        $app->response->setStatus(200);        echo json_encode($array);    }); 我已啟用CORS,并且GET請(qǐng)求有效。html使用服務(wù)器發(fā)送的JSON內(nèi)容進(jìn)行更新。但是我得到了XMLHttpRequest無法加載http:// localhost:8080 / server.php / post。飛行前的響應(yīng)具有無效的HTTP狀態(tài)代碼404每次我嘗試使用POST時(shí)。為什么?
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 914 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)