Js, PHP WITH AJAX: how to determine the letter grade of students using javascript with ajax?

Have you tested it?

yes it’s still the same

Your code is still wrong. Try making a request to here, http://stonecipherprojects.com/api/

Use Postman or whatever. If the request makes it to the server, it will tell you how

My test code:

<!doctype html>
<head>
    <title>Testing</title>
</head>
<body>
    <div id='score'>5</div>
    
<script>

    function GetXmlHttpObject()
{ 
 try {
   var xmlHttp = null;
   if (window.XMLHttpRequest)
   {
     // If IE7, Mozilla, Safari, etc: Use native object
     xmlHttp = new XMLHttpRequest()
   }
   else 
   {
     if (window.ActiveXObject)
     {
       // ...otherwise, use the ActiveX control for IE5.x and IE6
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
     }
   }

   return xmlHttp;
 } catch(e)
 {
   alert(e.message);
 }
}

var xhttp = GetXmlHttpObject();
var scoreElement = document.getElementById('score');
xhttp.open("post", "process.php", true);

xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
score = "score=5";
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
scoreElement.innerHTML = "Your Score: " + this.responseText;
console.log('Grade calculation complete');
}
}

xhttp.send(score);
</script>    
</body>
</html>
Sponsor our Newsletter | Privacy Policy | Terms of Service