“ 405(不允许使用方法)并且预检响应没有HTTP ok状态错误”

时间:2018-10-02 21:03:54

标签: http-status-code-405 preflight

我正在构建一个简单的Web应用程序,并且正在对Azure上托管的URL进行XMLHttpRequest()POST请求调用。我收到以下错误:

“ 405(不允许使用方法)” “预检响应没有HTTP ok状态错误”

我还启用了我的浏览器的CORS扩展程序。下面是我的代码:

var xhr = new XMLHttpRequest();    
var url = "MyURL" // URL is Correct, I verified!    
xhr.open("POST", url, true);    
xhr.setRequestHeader("Content-Type", "application/json");    
xhr.onreadystatechange = function () {       
  if (xhr.readyState == 4 && xhr.status == 200) {        
    var json = JSON.parse(xhr.responseText);        
    console.log("Data is: " + json);
  }
};

var obj = { SignId: getSignIdArr[temp] , BarCodeId: getBarCodeIdArr[temp],
  BaseType: getBaseTypeArr[temp], Condition: getConditionArr[temp],
  ConditionDate: getConditionDateArr[temp], Owner: getOwnerArr[temp], 
  Custodian: getCustodianArr[temp], FaceMaterial: getFaceMaterialArr[temp],
  FacingDirection: getFacingDirectionArr[temp], Height: getHeightArr[temp], 
  Illuminated: getIlluminatedArr[temp], MountType: getMountTypeArr[temp], 
  Notes: getNotesArr[temp], Code: getCodeArr[temp], 
  Description: getDescriptionArr[temp], Dimensions: getDimensionsArr[temp], 
  Type: getTypeArr[temp], Status: getStatusArr[temp], 
  Support: getSupportArr[temp], RetroRefTextSymbol: getRetroRefTextSymbolArr[temp], 
  RetroRefBackground: getRetroRefBackgroundArr[temp], 
  RetroRefTestFailed: getRetroRefTestFailedArr[temp], MaterialCost: getMaterialCostArr[temp], 
  LabourCost: getLabourCostArr[temp], InstallationCost: getInstallationCostArr[temp], 
  ReflectiveCoating: getReflectiveCoatingArr[temp], 
  ReflectiveRating: getReflectiveRatingArr[temp], 
  OptimisticLockField: getOptimisticLockFieldArr[temp], GCRecord: getGCRecordArr[temp], 
  NewSupport: getNewSupportArr[temp], SignGroup: getSignGroupArr[temp], 
  RetroRefDate: getRetroRefDateArr[temp], EquipmentCost: getEquipmentCostArr[temp] 
};

var data = JSON.stringify(obj);    
xhr.send(data);

任何帮助将不胜感激!坚持了一段时间。谢谢大家!

0 个答案:

没有答案