PHP Classes

File: js/core.js

Recommend this page to a friend!
  Classes of Adeleye Ayodeji   Simple OOP PHP Calculator   js/core.js   Download  
File: js/core.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Simple OOP PHP Calculator
Perform simple math operations between two numbers
Author: By
Last change:
Date: 3 months ago
Size: 1,341 bytes
 

Contents

Class file image Download
$(document).ready(function () { //Perform action if button clicked $("#submit").click(function (e) { e.preventDefault(); //Getting values from the fields const field1 = $("#field1").val(); const field2 = $("#field2").val(); const operator = $("#operator").val(); //Calling ajax function $.ajax({ type : "POST", url : "include/Result.php", data : { "add" : 1, "operator" : operator, "field1" : field1, "field2" : field2 }, success : function (result) { //Getting from json const jsonvalue = JSON.parse(result); $("#screencon").css({ "background" : jsonvalue.bg }); $("#screen").removeClass("text-dark"); $("#screen").addClass("text-white"); $("#screen").html(jsonvalue.result); //Getting values from the fields const field1 = $("#field1").val(); const field2 = $("#field2").val(); const operator = $("#operator").val(); //default for operate $("#topScreen").html(field1+"<span style='color:"+jsonvalue.bg+";font-weight:bold;'>"+jsonvalue.sign+"</span>"+field2); //console.log("Bg: "+jsonvalue.bg+" Result: "+jsonvalue.result); } }); // console.log(field1); }) });