2

I'm using JSON for cross domain my code is

var sourceCode = window.cseditor.getValue() || document.getElementById("sourcecode").value;
alert(sourceCode);
setStatus("Compiling...");


    $.ajax({
        type: "POST",
        url: "http://jsil.org/try/compile.aspx",
        contentType: "text/plain; charset=UTF-8",
        cache:false,
        dataType: "jsonp",
        data: sourceCode,
        success: compileComplete,
           error: function (xhr, status, moreStatus) {
               compileComplete(false, status + ": " + moreStatus);
           },
    });

The ajax response above code is:

"NetworkError: 400 Bad Request - http://jsil.org/try/compile.aspx?callback=jQuery172012547365785923736_1415796582452&%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20using%20System;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20using%20JSIL;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20using%20JSIL.Meta;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20public%20static%20class%20Program%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20public%20static%20int%20x%20=%2010;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20public%20static%20int%20y%20=%2020;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20public%20static%20void%20Main%20()%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dynamic%20document%20=%20Builtins.Global[%22document%22];%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20dynamic%20window%20=%20Builtins.Global[%22window%22];%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20canvas%20=%20document.createElement(%22canvas%22);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20ctx%20=%20canvas.getContext(%222d%22);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20var%20body%20=%20document.getElementsByTagName(%22body%22)[0];%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Console.WriteLine(%22Hello%20JSIL%20World!%22);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20body.appendChild(canvas);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20window.setInterval((Action)(()%20=%3E%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Redraw(ctx);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}),%2025);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20public%20static%20void%20Redraw%20(dynamic%20ctx)%20{%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20x%20+=%202;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.clearRect(0,%200,%20300,%20300);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.fillStyle%20=%20%22red%22;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ctx.fillRect(x,%20y,%2020,%2020);%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20&_=1415796586503"

Rob Baillie
  • 3,436
  • 2
  • 20
  • 34
Irshad
  • 141
  • 2
  • 12

1 Answers1

2

You are using JSONP. JSONP only supports GET requests.

Configure the server to return plain JSON (with the appropriate content-type and access control headers) and omit the dataType parameter (or set it to 'json').

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335