Jump to content

Opening and saving code


Mark.b

Recommended Posts

At the moment, when I use the URL given when HTML code is saved on the tryit board, it does not load up again.

In a similar fashion, any code written on the tryit board cannot be saved, you just get a loading icon spinning endlessly and the URL does not appear.

Any help woupd be appreciated!

 

Link to comment
Share on other sites

Yes. We are suffering the same problems.

(1) Unable to save HTML pages now.

(2) Saved HTML/JavaScript codes are gone (past links cannot bring back our codes.)

The site seems to have physical storage problems for the past few days.

Please help us to resolve the problems asap.

Thanks. 

Link to comment
Share on other sites

The following codes, which was directly copied from tryit editor source with alert()'s show that the php server codes does not accept saved data correctly now.

globalURL = 'https://tryit.w3schools.com/code_datas.php';

---------

<!DOCTYPE html>
<html>
<head>
<title>Simulation SaveFile of TryIt Editor</title>
<div id="preSave">preSave</div>
<div id="errorSave">errorSave</div>
<div id="postSave" style="color:red">postSave</div>
<hr>
<button onclick="saveFile(`document.getElementById('textareaCode').value`)">saveFile</button>
<hr>
<a id="shareLink" style="color:red" href="javascript:void(0);">shareLink</a>
<div id="shareLinkText" style="color:red">shareLinkText</div>
<div id="saveLoader" style="color:red">saveLoader</div>
<div id="saveModalSaved" style="color:red">saveModalSaved</div>
<script>
globalURL = 'https://tryit.w3schools.com/code_datas.php';

function saveFile(code) {

    alert('length='+code.length);
    
    document.getElementById('preSave').style.display='none';
    if (code.length>20000) {
        document.getElementById('errorSave').style.display='block';    
        return;
    }
    document.getElementById('postSave').style.display='block';    
    var paramObj = {};
    paramObj.code = code;
    var paramB = JSON.stringify(paramObj);
    alert('paramB= ' + paramB);
    var httpB = new XMLHttpRequest();
    httpB.open("POST", globalURL, true);

    httpB.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    httpB.onreadystatechange = function() {
        alert(httpB.readyState + httpB.status);
        if(httpB.readyState == 4 && httpB.status == 200) {

            if(httpB.responseText.substr(0,2) == "OK" ) {
              var getId = httpB.responseText.substr(2);
              document.getElementById("shareLink").href = "/code/tryit.asp?filename=" + getId;
              document.getElementById("shareLinkText").innerHTML = "https://www.w3schools.com/code/tryit.asp?filename=" + getId;
              document.getElementById('saveLoader').style.display = "none";
              document.getElementById("saveModalSaved").style.display  = "block";
            } // "OK"
        } // 4 && 200
    } // onreadystatechange
    httpB.send(paramB);
}
</script>
</head>
<body>

<h1>This is a test/simulation on W3Schools saveFile() function</h1>
<p>Post to <script>document.write(globalURL);</script> is being tested.</p>
<p style="color:red">Status codes: 202, 203, 204 are returned</p>
<p>204: Empty Content. Server successfully executed request but without return anything.</p>

</body>
</html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...