Spaces:
Runtime error
Runtime error
| /** | |
| * helper functions defined | |
| */ | |
| function handle_one_return(output) { | |
| return output; | |
| } | |
| function handle_two_return(output1, output2) { | |
| return [output1, output2]; | |
| } | |
| /** | |
| * | |
| * @param {string} url from javascript to flask(python) with route | |
| * @param {dictionary} data from javascript to flask(python) with data | |
| * @param {function} handle ν° μλ―Έ μμ | |
| */ | |
| function sendAjax(url, data, handle) { | |
| /* | |
| jQuery.getJSON(url, [, data], [, success]) | |
| Load JSON-encoded data from the server using a GET HTTP request. | |
| */ | |
| $.getJSON(url, data, | |
| function(response) { | |
| handle(response.result); | |
| } | |
| ); | |
| } | |
| /** | |
| * | |
| * @param {string} url from javascript to flask(python) with route | |
| * @param {dictionary} data from javascript to flask(python) with data | |
| * @param {string} dataType The type of data that you're expecting back from the server. (ex. "json") | |
| * @param {function} handle ν° μλ―Έ μμ | |
| * @returns from flask(python) to javascript with data | |
| */ | |
| function sendAjax_sync(url, data, dataType, handle) { | |
| /* | |
| jQuery.ajax(url, [, settings]) => Synchronous ( λκΈ°μ : μ½λ μμλλ‘ μ§ν ) | |
| jQuery.getJSON => Asynchronous (λΉλκΈ°μ) | |
| */ | |
| var search_var; | |
| $.ajax(url=url, settings={data: data, dataType: dataType, async: false, | |
| success: function(response) { | |
| search_var = handle(response.result); // handle, ν° μλ―Έ μμ | |
| } | |
| }); | |
| return search_var | |
| } | |
| /** | |
| * | |
| * @param {string} url from javascript to flask(python) with route | |
| * @param {dictionary} data from javascript to flask(python) with data | |
| * @param {string} dataType The type of data that you're expecting back from the server. (ex. "json") | |
| * @param {function} handle ν° μλ―Έ μμ | |
| * @returns from flask(python) to javascript with data | |
| */ | |
| function sendAjax_sync_about_chartData_and_newsArticles(url, data, dataType, handle) { | |
| /* | |
| jQuery.ajax(url, [, settings]) | |
| jQuery.getJSON => Asynchronous (λΉλκΈ°μ) | |
| Synchronous => λκΈ°μ : μ½λ μμλλ‘ μ§ν | |
| */ | |
| var chart_data; | |
| var news_articles; | |
| $.ajax(url=url, settings={data: data, dataType: dataType, async: false, | |
| success: function(response) { | |
| [chart_data, news_articles] = handle(response.chart_data, response.news_articles); // handle, ν° μλ―Έ μμ | |
| } | |
| }); | |
| return [chart_data, news_articles]; | |
| } | |