ajax

Passing localstorage to controller using Ajax

只愿长相守 提交于 2021-02-07 09:24:25
问题 I need to access the data held in localstorage, server side but that's another story. I have this button in my view: <div style="float:right;"> <input id="btnTest" type="button" name="test Json Button" value="test Json Button" onclick="sendLocalStorage();" class="btn btn-default" /> </div> This JS function: function sendLocalStorage() { var JsonLocalStorageObj = JSON.stringify(localStorage); //var test = ["test1", "test2", "test3"]; $.ajax({ url: "/MyControllersName/Test", type: "POST",

Jquery progress bar server side

僤鯓⒐⒋嵵緔 提交于 2021-02-07 09:14:15
问题 I have a long running process(not definite time) in server-side(which runs number of queries in db) which takes more than 30s. I want to display the progress in % to the user. I'm using jquery ,struts in my application. Is there a way to do it? 回答1: This is how we did it. When the process is triggered create a GUID from the client and pass it to the server. In the server side, run the process and during the run, keep storing the progress in session/cache using the GUID as key. In the client

Can I use AJAX 'POST' to post data to a JSON file on my server?

佐手、 提交于 2021-02-07 08:03:45
问题 I just want the easiest/most simple way to get my data from an AJAX form using 'POST' the data the user entered on my server. So if the user leaves their name in the input form on the page, then AJAX POST's the data to a JSON file on my server. Is this possible? Is this the quickest way to get the data that is entered? Thanks in advance! *can someone tell me why this got downvoted? Am I violating any terms? I would just like to know in the future. Thanks. :/ 回答1: Ajax file directly can not

Can I use AJAX 'POST' to post data to a JSON file on my server?

南笙酒味 提交于 2021-02-07 07:59:33
问题 I just want the easiest/most simple way to get my data from an AJAX form using 'POST' the data the user entered on my server. So if the user leaves their name in the input form on the page, then AJAX POST's the data to a JSON file on my server. Is this possible? Is this the quickest way to get the data that is entered? Thanks in advance! *can someone tell me why this got downvoted? Am I violating any terms? I would just like to know in the future. Thanks. :/ 回答1: Ajax file directly can not

Uncaught TypeError: $.ajax(…).error is not a function

放肆的年华 提交于 2021-02-07 07:18:16
问题 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>jquery examples - 4</title> <link rel="stylesheet" type="text/css" href="css/style2.css"> </head> <body> <input id="name" type="text" name=""> <input id="button" type="button" value="load" name=""> <div id="content"></div> <script type="text/javascript" src="js/jQuery.js"></script> <script type="text/javascript" src="js/selectors12.js"></script> </body> </html> $('#button').click(function() { var name = $('#name').val(); $.ajax({ url

Refresh the Bar Char in ChartJS (v2.6.0) Using Ajax Correct Way

房东的猫 提交于 2021-02-07 06:48:42
问题 I am refreshing my Bar Chart on change of a drop down. I just Want to know that am I doing it in correct way. In my code every time I am replacing my existing canvas with new one. Is there any better way to achieve same thing? My JS Code: var chart_= function () { $('#canvas_id').replaceWith('<canvas id="canvas_id" style="height:280px"></canvas>'); $.ajax({ type: 'POST', //post method url: 'url', //ajaxformexample url dataType: "json", success: function (result, textStatus, jqXHR) { //

ajaxStart and ajaxStop equivalent with fetch API

微笑、不失礼 提交于 2021-02-07 06:00:08
问题 I'm trying to migrate my API calls from using jQuery ajax to using the Fetch API. I was using jQuery ajaxStart and ajaxStop to display a loading spinner during server calls. I'm running several parallel server requests, I want the spinner to start when the first request start and to stop when the last request settled. It was pretty straight foward with jQuery. However, I can't find a similiar technique using the fetch API. Any ideas ? 回答1: You can use Promise to notify when fetch is called

AJAX post not working with HTTPS

為{幸葍}努か 提交于 2021-02-07 05:52:27
问题 I am having a rather frustrating problem with the jquery post function that probably stems from not understanding how it works correctly. I have a function that should post some form information to a php script that I wrote and that script then runs curl requests against an API to get around the cross-domain policy of javascript. It seems to work fine as long as it submits to "http" but when I send it to "https" the form never gets submitted. I ran wireshark on my computer and it showed no

AJAX post not working with HTTPS

女生的网名这么多〃 提交于 2021-02-07 05:52:16
问题 I am having a rather frustrating problem with the jquery post function that probably stems from not understanding how it works correctly. I have a function that should post some form information to a php script that I wrote and that script then runs curl requests against an API to get around the cross-domain policy of javascript. It seems to work fine as long as it submits to "http" but when I send it to "https" the form never gets submitted. I ran wireshark on my computer and it showed no

jquery Select2 prevent selecting in ajax response

懵懂的女人 提交于 2021-02-07 05:46:47
问题 I want to prevent from adding a category to the Select2 element if it fails creating the row first in my db. The action is not prevented when i call ev.preventDefault(); Nothing happens.. what is wrong? $('#sel2').select2({ placeholder: 'Enter categories', minimumInputLength: 3, multiple: true, ajax: { url: 'async/get_categories.php', dataType: 'json', quietMillis: 250, data: function (term, page) { return { q: term, }; }, results: function (data, page) { return { results: data.items }; },