Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please use POST request in JSfiddle

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);
}​​​​​
like image 247
Aido Avatar asked Jul 17 '12 18:07

Aido


1 Answers

document.forms.form.submit();

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: 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.

like image 197
Rocket Hazmat Avatar answered Oct 21 '22 14:10

Rocket Hazmat