From cd0981b2df8f044f528191ed0771222dd742a680 Mon Sep 17 00:00:00 2001 From: Commander-lol <ljcapitanio@gmail.com> Date: Sun, 2 Nov 2014 13:07:33 +0000 Subject: [PATCH] Added muTest to perform (very primitive) testing Added an extra file (test.js) to store various tests under muTest, a php file to respond to requests and an update for test.html to include test.js --- js/test.js | 14 ++++++++++++++ test.html | 3 ++- tests/jsonresponse.php | 9 +++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 js/test.js create mode 100644 tests/jsonresponse.php diff --git a/js/test.js b/js/test.js new file mode 100644 index 0000000..df720b3 --- /dev/null +++ b/js/test.js @@ -0,0 +1,14 @@ +if(!mu.exists(window.muTest)){ + window.muTest = { + postJsonResponse: function(){ + mu.ajax({ + url: 'tests/jsonresponse.php', + method: 'POST', + responseType: 'json', + success: function(data){ + console.log(data); + } + }); + } + } +} diff --git a/test.html b/test.html index 4f9a54c..06eda26 100644 --- a/test.html +++ b/test.html @@ -13,7 +13,7 @@ so it would be <span class='important'>bad</span> if any of them dissapeared. </p> <p id='emptydiv'> - + </p> </div> @@ -45,6 +45,7 @@ </body> <script type="text/javascript" src="js/tinyDOM.js"></script> + <script type="text/javascript" src="js/test.js"></script> <script type="text/javascript"> μ('#btn-show').on('click', function(){ μ('.important').show(); diff --git a/tests/jsonresponse.php b/tests/jsonresponse.php new file mode 100644 index 0000000..6a32ea9 --- /dev/null +++ b/tests/jsonresponse.php @@ -0,0 +1,9 @@ +<?php header('Content-Type: application/json'); + $jsonObj = array( + 'elementOne' => 'Its a string', + 'numberElement' => -1, + 'booleanElement' => True, + 'elementTwo' => 'another string!' + ); + echo json_encode($jsonObj); +?> -- GitLab