ajax

Difference between EventSource and XMLHttpRequest for SSE

拜拜、爱过 提交于 2021-01-28 08:03:39
问题 I am implementing a Server Send Event application logic. The server side is done and I'm dealing now with the client part. Everywhere I look, the JS is using an EventSource Object, which seems higly logical as it is made for it ! But which has also a lot of limitation (only GET requests, no headers, no data ...) I am asking myself : why not using an XMLHttpRequest Object instead ? The server I am accessing to is written in Java EE and returns a text/event-stream typed response. Here are my

Showing Data in MySQL Database In Realtime

▼魔方 西西 提交于 2021-01-28 07:51:03
问题 I am building a weather station that will update the weather in "real-time" to a MySQL Database. To give the feel of "real-time" without taking up a ton of space on my MySQL server, I have my weather station updating a single cell in the MySQL database every few seconds. I would like to set up a way for a website to view this change in realtime without refreshing the page. I have tried researching a lot, but I can't quite find what I am looking for (at least with more of an explanation into

Magento get last product added to cart

对着背影说爱祢 提交于 2021-01-28 07:29:58
问题 i need to get the last product added to cart, with all informations: image, name, sku and custom options if product is configurable. I try with this code but is not working. My Magento version is 1.9.1 $xitems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems(); $max = 0; $lastItem = null; foreach ($xitems as $xitem){ if ($xitem->getId() > $max) { $max = $xitem->getId(); $lastItem = $xitem; } } if ($lastItem){ $_xproduct = $lastItem->getProduct(); $xproductsku = $_xproduct-

How to update variable on a foreach in blade laravel with js

僤鯓⒐⒋嵵緔 提交于 2021-01-28 07:09:09
问题 I have a page which loads both folders and files available on my database : Like you can see in the picture, files loaded on a first time load all the files availables on all folders with the following code : public function index(){ $folders = Folder::where('user_id', '=', auth()->id())->get(); $data = collect(); $filator = collect(); // loop around the folders foreach ($folders as $f){ $files = DB::table('files') ->where("folder_id",'=',$f->id)->count(); // loop around the files in all

How can I write tests that have setup and teardown operations that are asynchronous?

百般思念 提交于 2021-01-28 07:03:09
问题 I am using a library (pouchDB) that does some async operations. To keep things simple, I will keep the details out of it as I think this is a general issue with "unit testing" involving async operations (unit testing in quotation marks because I guess this isn't truly unit testing if I am testing integration with another library. But, using QUnit seems like the most appropriate way to write tests for it). I am using QUnit to do my js unit testing. I have two tests. I am finding that if I run

AJAX and PHP get files and folders list using RecursiveIteratorIterator as needed

元气小坏坏 提交于 2021-01-28 07:02:40
问题 I need get list of files and folders from server. I don't want get all files, folders, sub-folders at once. I want get theirs little by little, as needed. So I use AJAX. I use PHP. I use RecursiveIteratorIterator. I did it without AJAX, but I can't do it using AJAX : It works only for first directory (~root directory). I can't pass $name variable in function. **Not JQuery!!!** PHP <?php if (isset($_GET['you_choose_directory'])){print "do something";} getList("/start_folder/"); //always(

How to make post ajax call with JSON data to Jersey rest service?

你离开我真会死。 提交于 2021-01-28 07:00:30
问题 I have been through this link. but this did not helped me out. I am using jersey lib v1.17.1. My jersey rest service: @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) @Path("/post1") public ResponseBean post1(@QueryParam("param1")String param1) { return ResponseFactory.createResponse(param1, "TEST", "TEST", null, true); } url is: /test/post1 My ajax call: var d = {"param1":"just a dummy data"}; $.ajax({ type : "POST", url : "http://localhost:7070/scl/rs

How to Upload Files using ajax call in asp.net?

江枫思渺然 提交于 2021-01-28 06:32:26
问题 I have created a small asp.net web forms application, to manage emails , i have created a little interface contains mandatory information to send a email, like from , to , subject etc. now i want to attach files to the email, i have used asp.net file upload controller to upload files, and have to attach multiple files, Now i want to send this details to code behind, so i thought the best way is to use ajax calls , because i don't want to refresh my page, but i can't figure out the way how to

is it possible to receive only partial results in JSON from API calls using PHP?

送分小仙女□ 提交于 2021-01-28 06:25:39
问题 I have been using PHP to call an API and retrieve a set of data in JSON.I need to make 20 batch calls at once. Therefore, speed is very important. However, I only need the first element, in fact, I only need one data which is right at the beginning of the JSON file, index 0. However, the JSON file returns about 300 sets of data. I have to wait until all the data are ready before I can proceed. I want to speed up my API calls by eliminating redundant datasets. Is it possible for me to receive

what is the alternative of FormData in IOS?

不羁岁月 提交于 2021-01-28 06:25:00
问题 I'm using xmlHTTPRequest (and also $.ajax) to send a form(that contain some text inputs and multi-file input) without refreshing the page. I'm using FormData to send the form successfully on PC (Chrome). When I run the page in my IPAD (IOS), it didn't work. After trying to know where the error was, it seemed that FormData not supported in it. Is there any alternative for it in my case ? var formDataH = new FormData($('#FeedbackForm')[0]); var xhttp = new XMLHttpRequest(); xhttp