请在JSfiddle中使用POST请求 [英] Please use POST request in JSfiddle

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

问题描述

每当我运行我的代码时,我都会收到错误 {error:请使用POST请求} 有谁知道这个错误意味着什么?
我在jsfiddle中的代码: http://jsfiddle.net/Aidoboy/AdzwC/12/
代码:

Whenever I run my code, I get the error {"error": "Please use POST request"} Does anyone know what this error means? My code in jsfiddle: http://jsfiddle.net/Aidoboy/AdzwC/12/ the code:

/*jslint browser: true, devel: true */

function Submit() {
    //"use strict";
    alert("running");
    document.forms.form.submit();
    var owed = 0;

    function calc(n, o) {
        if (n >= 90) {
            owed = owed + 1;
            if (n >= 95) {
                owed = owed + 1;
            }
        }
        else if (o >= 80) {
            owed = owed + 0.5;
        }
        if (n > o) {
            owed = owed + 0.5 * (n - o);
        }
        if (n < o) {
            if (n < 95) {
                owed = owed - 0.25;
            }
        }
        if (n == 94) {
            if (o == 97) {
                owed = owed + 0.25;
            }
        }
    }
    calc(form.Math.value, form.OMath.value);
    calc(form.Sci.value, form.OSci.value);
    calc(form.ELA.value, form.OELA.value);
    calc(form.SS.value, form.OSS.value);
    calc(form.Elec1.value, form.OElec1.value);
    calc(form.Elec2.value, form.OElec2.value);
    calc(form.Elec3.value, form.OElec3.value);
    calc(form.Elem1.value, form.OElem1.value);
    calc(form.Elem2.value, form.OElem2.value);
    calc(form.Elem3.value, form.OElem3.value);
    alert(Owed);
}​​​​​


推荐答案

document.forms.form.submit();

这实际上提交< form> ,你不能在jsFiddle 1 中做到这一点。只要删除该行,如果要运行JavaScript,为什么要提交表单?

This actually submits the <form>, you can't do that in jsFiddle1. Just remove that line, if you want to run the JavaScript, why are you submitting the form?

1:你可以,但不使用< form> 。您可以测试AJAX,请参阅文档。您收到错误请使用POST请求,因为默认情况下< form> 使用GET。 jsFiddle不喜欢被发送一个查询字符串,所以它给出了这个错误。你可以 POST东西给它,但什么都不会发生。

1: You can, but not using a <form>. You can test AJAX, see the docs. You're getting the error "Please use POST request" because by default <form> use GET. jsFiddle doesn't like being sent a query string, so it gave that error. You can POST stuff to it, but nothing will happen.

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

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