php - Ajax behaving differently on Firefox -


i trying check progress of file download. this, repeatedly polling php file(progress_sess.php) echoing session value being changed in file handling download (export.php). there 1 ajax request export.php , multiple ajax requests progress_sess.php. way able display phase file download script in. working out in chromium. clear requests, can see image here: - chromium requests.

in firefox error thrown: -

json.parse: unexpected end of data @ line 1 column 1 of json data 

you can see request here: - firefox requests when echo xhr.responsetext in firefox, gives this: -

"" 

this possibly because in chromium can see in image, requests application/json, specified in progress_sess.php header, whereas in firefox first request inexplicable reason text/plain?! not understand why firefox getting text/plain response header.

you can see progress_sess.php: -

<?php     session_id($_cookie['phpmyadmin']);     session_start();     header("content-type: application/json");     $result = $_session['export_progress'];     if ($result==null)      {         $result = '';     }     $arr = array(progress_result=>$result, source=>'progress_sess.php');     echo json_encode($arr); ?> 

so impossible there wrong json. guess question is, why throwing json parse error when have explicitly specified header? because of text/plain request header, or due ajax differences between firefox , chromium.

seems response not valid json-string. https://developer.mozilla.org/en/docs/web/javascript/reference/global_objects/json/parse


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -