三生石@ 2018-08-08 12:03 采纳率: 100%
浏览 56

错误400与Ajax请求

I am new to web development, and I guess that it is a basic issue, but I couldn't find a solution on the internet.

To start, what I am trying to do is to have a script, loaded on a webpage using TamperMonkey, download a xml file located on a php server.

The process worked perfectly when I tested it on localhost (using MAMP), but then I put it on a 000webhost server, and it's not working, I get an Error 400 Bad request in the ajax response. I also tried on other web hosting services and I get the same error.

On the other hand, the request works perfectly on the 000webhost server when I'm just sending it though my google chrome searchbar. Also, the url to which it is sent is well formed, as when I console.log it, and then click the link, it does what it should.

I am using the GM_xmlhttpRequest method. Here is the code :

let url = some_correct_url;
GM_xmlhttpRequest({
        methode: "GET",
        url: url,
        headers: {
            "Accept": "text/xml"
        },
        onload: function(response){
            var r= null;
            if (!response.responseXML){
                r= new DOMParser().parseFromString(response.responseXML, "text/xml");
            }
            r= response.responseXML;
            console.log(r);
            console.log(response.responseText);
            });
        });
  • 写回答

1条回答 默认 最新

  • 北城已荒凉 2018-08-08 12:16
    关注

    You have a typo in your request body.

    Typo: methodE: "GET"

    Please correct the typo so it reads method: "GET" and let us know the results.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题