NS_Error_Failure在Javascript POST上 [英] NS_Error_Failure on Javascript POST

查看:27
本文介绍了NS_Error_Failure在Javascript POST上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用一些JavaScript时遇到了麻烦.下面的代码段创建了一个简单的发布请求,但始终会引发 NS_Error_failure 异常(详细信息在页面底部).谁能告诉我这段代码有什么问题吗?

I am having trouble with some javascript. The code snippet below creates a simple post request however it always throws an NS_Error_failure exception (details at the bottom of the page). Can anyone tell me whats wrong with this code?

window.onload = function () {

    alert('0');
    try {
        var url = "Some URL";
        var request = CreateHttpRequest();
        if (request) {
            alert('1');
            request.open("POST", url, false);
            request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            alert('2');
            request.send('');
            alert('3');
        }
    }
    catch (err) {
        alert(err);
    }
}

    [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)"
     nsresult: "0x80004005 (NS_ERROR_FAILURE)"  
     location: "JS frame :: file:///C:/Users/Ben/Desktop/test.html :: <TOP_LEVEL> :: line 44"  data: no]

推荐答案

可以看到此错误,

  1. 未找到网址
  2. 您的服务器代码或称为URL的错误.

您共享的代码中没有任何可见的问题.请参阅此链接

There is not any visible problem in code you shared. Please refer this link

这篇关于NS_Error_Failure在Javascript POST上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆