zoukankan      html  css  js  c++  java
  • post跨域请求webservice接口

      尝试解决这个问题花费将近一天时间,又好好对ajax理解了一遍。问了别人调过webservice接口的人说都是用post请求,然后post请求就不能用jsonp跨域,然后改了一下ajax,

    $.ajax({
      type: "post",
      //contentType: "application/json;charset=utf-8", //如果是xml则WebService 会返回xml类型 
      url: url,
      dataType: "json",
      //jsonp: 'jsoncallback',
      data:{
        Interface:"",
        Interface_method:"",
        xmlData:""
      },
      /*beforeSend: function (x) { 
        x.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); 
      }, */
      success: function (response) { //回调函数,result,返回值 
        console.log(response);
        alert(1);
      },
      error:function(msg,textStatus,xhr){
        console.log(msg);
        alert(textStatus);
        console.log(xhr.responseText);
      });

      不知道问题在哪的时候用这个判断一下:

    error:function(){ 
        alert(XMLHttpRequest.status);
        alert(XMLHttpRequest.readyState);
        alert(textStatus);
      }

      一直跳到error函数,报500的错误,控制台输出一串:

    Object {readyState: 4, responseText: "<?xml version="1.0" encoding="utf-8"?><soap:Envelo…etail /></soap:Fault></soap:Body></soap:Envelope>", status: 500, statusText: "Internal Server Error"}

      原来以为是跨域问题没解决,看一下headers发现后台有加请求头,现在真是懵逼了

  • 相关阅读:
    MySql存储过程学习
    自己用C语言写的扫雷算法
    Spring学习——Hello World
    ICE Service使用方法简介
    DevExpress学习笔记(一)Ribbon
    DevExpress学习笔记(二)NavBarControl
    ORACLE DBLINK无法使用问题
    vbs脚本读写INI文件
    Python操作INI文件:configobj 更好
    个人发展的误区:越广越好,还是越深越好?
  • 原文地址:https://www.cnblogs.com/yaoya/p/7093238.html
Copyright © 2011-2022 走看看