-
-
Save mohayl/68632bcf8933affddf893a429b2953fe to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ #main { width: 400px; } #container { width: 400px; } #answer { font-color: red; font-size: 18pt; } body { background: #FFFFFF; font-family: 'Open Sans', sans-serif; } .logo_container { margin-top: 5px; margin-bottom: 6px; float: left; width: 200px; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <h2>MATLAB Production Server (JSON request example)</h2> <div id="main"> <label><span>Compute the Nth Fibonacci number (Please enter N):</span> <input type="text" class="n" name="fn"> </label> <input type="button" value="submit"> </div> <div id="container"> <p>Result from MATLAB:</p> <div id="answer"></div> </div> <div class="logo_container hidden-xs hidden-sm"> <a href="http://www.mathworks.com/index.html?s_tid=gn_logo" class="svg_link pull-left"> <img src="http://www.mathworks.com/images/responsive/global/pic-header-mathworks-logo.svg" class="mw_logo" alt="MathWorks"> </a> </div> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ $(document).ready(function() { $('input:button').click(function() { if (isNumeric($("input:first").val()) == true) { /* Call MATLAB Production Server */ var n = Number($("input:first").val()); computeFibonacciMPS(n); } else { $('#answer').text("Input needs to be numeric!"); } }); }); /* Function to compute Fibonacci series on MATLAB Production Server */ function computeFibonacciMPS(n) { /* Create a simple AJAX request to the MATLAB Production Server */ $.ajax({ url: 'http://ec2-34-206-1-112.compute-1.amazonaws.com:31415/example/fibonacci', type: "POST", data: JSON.stringify({ "rhs": n, "nargout": 1 }), contentType: 'application/json', success: function(data) { /* Parse the response when ready */ $('#answer').text(data.lhs[0].mwdata[0]); $('#answer').effect("highlight", { color: "#FFFF00" }, 1000); //console.log(data); } }); } /* Helper function to determine if input is numeric */ function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); }