Menu
  • HOME
  • TAGS

Multiple onprogress event handlers from xhr in loop

javascript,html5,xmlhttprequest

You need to scope your file name in the progress callback, currently it will only use the last value of i. Replace where you set your onprogress handler with this code. (function(filename) { xhr.upload.onprogress = function (e) { if (e.lengthComputable) { var percentComplete = (e.loaded / e.total) * 100; console.log(percentComplete...

Setting CORS call to GET not OPTIONS

javascript,xmlhttprequest,authorization,cors

If you set an Authorization header then you are making a complex request and you have to handle the OPTIONS preflight before the browser will make the GET request. You can't set the header without handling the OPTIONS request....

Angular JS : Failed to execute 'send' on 'XMLHttpRequest'

angularjs,xmlhttprequest

As @Puneetsri said, the best option is to host your files on a web server. Otherwise try launching your app in chrome after starting it with the following flags chrome.exe --allow-file-access-from-files ...

unable to set xhr.responseType using chrome 43 beta

javascript,google-chrome,xmlhttprequest,chromium

It seems we use pdf.js package in our app, which has a compatibility.js file that defines a setter function "responseTypeSetter", that doesn't let us to set the XMLHttpRequest's responseType to 'blob' or anything else. Upgrading compatibility.js to a newer version had solved this problem....

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience

javascript,asynchronous,xmlhttprequest

Since $.load() is just a simplified function of a normal $.ajax() call, you can use the $.ajaxPreFilter() to set specific options before each request is sent and before they are processed by $.ajax(). $.ajaxPrefilter(function( options, originalOptions, jqXHR ) { options.async = true; }); By default, this is set to true...

Override incorrect declared text encoding in XML document using XMLHttpRequest

internet-explorer,character-encoding,xmlhttprequest,windows-1252

if you initially read the file with xhr.responseType="arraybuffer", then blob it with your desired mime/charset like such: new Blob([ arraybuff ], {type: 'application/xml;charset=windows-1251'}) then create a blobURL for it via URL.createObjectURL(blob), and finally, xhr that, I think it will work. Here's an online test. ...

always_populate_raw_post_data - Trouble accessing request payload from Backbone create

php,backbone.js,xmlhttprequest,slim,postdata

There is a bug in PHP 5.6. Default value of always_populate_raw_post_datais 0. This causes PHP to throw warnings even if your code does not use $HTTP_RAW_POST_DATA. Some claim it happens when calling header() after some text has already been outputted. Trying to use ini_set()does not help. You must change the...

Busboy doesn't fire 'field' event

angularjs,node.js,xmlhttprequest,busboy

not busboy.on('ident', function(fieldname, val) {})); you must try: busboy.on('field', function(fieldname, val) { /*get all non-file field here*/ }); ...

Send a POST XMLHttpRequest with a body to an express node server

node.js,http,post,express,xmlhttprequest

Well I solved my issue using cURL, so not the best answer but here was what I used curl -d "xml_in=http://google.com&c2=12345" http://192.168.1.1:3000/secondPage ...

How i can doing for call a object with a dot in middle, for example parsing one xml to php?

php,codeigniter,xml-parsing,xmlhttprequest

Access the element as follows $myvalue = $xml->obj1->{'obj1.1'}['value']; Originally answered here http://stackoverflow.com/a/5351141/3944304...

'Access is denied' error for HTTP get request in Adobe Air App using IE

angularjs,internet-explorer,webview,air,xmlhttprequest

I resolved the issue by starting a local http server and hosting my xml files on it. This way the http get request had a url of the form http://localhost:<port>/myLocalFile.xml and got around the cross domain issues. This worked perfectly for me! Thanks to the contributors of the links below...

“Synchronous XMLHttpRequest on the main thread is deprecated” using nodejs app.get or http-server

node.js,express,xmlhttprequest,synchronous,http-server

Thanks for the comments. I have tracked down the issue, and it is within Chrome - more particularly extensions. The issue is with an extension I have: PropertyWizza v2.0. Disabling this extension clears the problem. I will now uninstall it so it doesn't interfere with my development messages. This was...

Will a cross site XMLHTTPRequest ever re-use credentials?

javascript,xmlhttprequest,csrf,http-basic-authentication

As long as you don't have the Access-Control-Allow-Credentials response header set, it will not allow authorisation for API requests that read data (the request will still be made, although the response cannot be read by the other domain due to the Same Origin Policy). You still should implement CSRF protection...

XMLHttprequest not working the twitch.tv api

javascript,api,xmlhttprequest,twitch

The Twitch.tv API doesn't support CORS. You need to use JSON-P (aka JSONP) to work around it. Read more about that in the Twitch.tv API docs. There is a prior answer on how to make a JSONP request with native JavaScript that may be useful.

Ruby on Rails: output JSON data from array

html,ruby-on-rails,ruby,json,xmlhttprequest

You should either use respond_to block (in case your action handles multiple formats) or explicitly state that you want to render json (easier in case your action only handles json): class SomeController < ApplicationController def some_action @data = Data.find(1) @string_json = '{ "key": "value" }' render json: @data # render...

When Promisifying a XMLHttpRequest, how to catch a throw Error

javascript,xmlhttprequest,promise

The problem is, that the error gets thrown before your then block gets called. Solution Request .get('http://google.com') .catch(function(error) { console.error('XHR ERROR:', error); }) .then(function(responseLength) { // log response length console.info(responseLength); // throw an error throw new Error("throw error"); }) .catch(function(error) { // e.target will have the original XHR object console.error('SOME...

JavaScript: XMLHttpRequest() from Firefox addon to get zip

javascript,firefox,xmlhttprequest,firefox-addon,zip

I'm almost dont, I'm just stuck on figuring out how to use the asynchronus zip.js module. You can use nsIZipWriter and nsIZipReader like the linked addon does from my comment. But I think async is just better so I'm working on that: https://github.com/Noitidart/AysncZip/blob/master/bootstrap.js Install the addon, click on the toolbar...

CORS issue with asynchronously loaded JavaScript through dynamically created script tags

javascript,html,ajax,xmlhttprequest,cors

XMLHttpRequest objects are used for asynchronous data exchange with AJAX. Is it the same object used for asynchronous script loading with dynamic script tags? No, the browser just loads them as it does scripts in general. If so, does the CORS(Cross Origin Resource Sharing) issue applies here too ?...

xmlhttprequest request sent, but code not executed?

javascript,php,xmlhttprequest

I guess, if no file is being shown... you might be missing enctype="multipart/form-data" in your form.

Undefined $_POST after xmlhttp request

javascript,php,mysql,ajax,xmlhttprequest

I actually solved it myself by accident. It turns out the error is that the program is halting at the point that it tries to delete all pages associated with a comic. When it is presented with an already empty comic, it tries to delete nonexistent records. Manually adding a...

Javascript: Sending arrayBuffer using XMLHttpRequest

javascript,xmlhttprequest,multipartform-data,arraybuffer

Notice that the Blob constructor takes an array of typed arrays (or other sources) as its parameter. Try form.append("picture", new Blob([fileAsArray], {type: "image/jpg"} )); ...

Why I'm not entering into sucess event of $.ajax request [closed]

jquery,ajax,xmlhttprequest,sendasynchronousrequest

Because of simple typo in your code, there is nothing wrong in your code success: function (result) { //-^-------------- alert("into sucess"); $('#para').innerHtml = result; }, ...

Simple XMLHttpRequest function to return a JSON object

javascript,jquery,json,xmlhttprequest

You should use this construction function sendRequest(_path, cb) { req = new XMLHttpRequest() req.open('GET', apiEndpoint+_path); req.onreadystatechange = function() { if (this.readyState === 4) { cb(JSON.parse(this.response)); } else{ cb(null); } } req.send(); } // Action sendRequest('client1/', function(result){ console.log(result); }) For asynchronous calls you need to use call backs...

Uploading GPX file to Strava API with GTMHTTPFetcher POST in Objective-c

ios,objective-c,http,post,xmlhttprequest

So I turned out formatting the body myself and I learned about how to accomplish this with the help of the example in the following link: http://nthn.me/posts/2012/objc-multipart-forms.html. I experienced troubles with the last boundary though because it needed an extra -- afterwards which was missing in the example. Luckily I...

AWS API signed POST request with Javascript

javascript,amazon-web-services,http-headers,xmlhttprequest,amazon-kinesis

The Host: header is being filled in and parsed from the given URL by the JS XHR itself when you execute it, same as with curl, e.g. curl -v -X POST http://example.org/foo ...will automatically add the header Host: example.org... For AWS you'll still need to add it to the canonical_headers...

XMLHttpRequest() is not working in Firefox.

firefox,xmlhttprequest

Either do it like this so the page get reloaded after the request is done, or just skip the ajax and use a regular link $.get("?idioma=1", function() { location.reload(); }); ...

Comet streaming: XHR streaming and Forever iFrame still possible in 2015?

iframe,xmlhttprequest,streaming,comet

In our experience, XHR Streaming is still working properly on all browsers. You can see it working in any of our demos, after switching off WebSockets. Do like this: Go to http://demos.lightstreamer.com/StockListDemo_Basic/ Click on the top-left "S" icon to expand the widget and see the transport state; you should see...

IE8 changing GET request to POST: Angular $http

javascript,angularjs,http,internet-explorer-8,xmlhttprequest

I think I have found the solution. We need to send empty string as payload. Or, use $http.get

Server-side requests and XmlHTTPRequest (client-side) and security

javascript,security,xmlhttprequest,cross-domain,same-origin-policy

When my browser makes a request to a website it includes a lot of information about me (such as my ip address and any cookies I have for that website) that can be used for authentication. If you were to use XMLHttpRequest to make a request to another site, it...

Why does my XMLHttpRequest not allow XSS?

javascript,xmlhttprequest,client,cors,xss

After more research. It seemed that the easiest solution was to create my own proxy. Convert the static site into a blank ASP.Net Web Application Create a generic handler in the project that contacts the bbc feed from the server Call that handler from the client side JS Here is...

Read/Write the cookies from an XHR request/response (PhoneGap/Cordova)

cordova,http,cookies,xmlhttprequest,phonegap-plugins

I confirm that cookies are not manageable from JavaScript's XMLHttpRequest object in PhoneGap/Cordova on Android, regardless of the framework used (so not an angular issue). It seems to be a feature, not a bug, with no plans to expose the cookies down to the JavaScript side (the cookies are managed...

Displaying table from PHP in HTML through AJAX

javascript,php,html,ajax,xmlhttprequest

Considering that you database.php file is giving out correct data back. a) Error :- You are not using return false on form submit handler , just add return false and things will work for you b) Suggestion 1) You are attaching the checkFields() function 2 times, once on submit button...

How to reuse JSON data that may have changed?

javascript,json,d3.js,xmlhttprequest

you are editing data on your JSON file so that when you return to that JSON file the second time, it has been altered so you cant use it in the same way as before

Sending xml request to url and receiving xml response back

c#,asp.net-mvc,xmlhttprequest,httpwebrequest

Here is one way you could do this, which is basically a form post. var xmlRequest = new XElement("CityStateLookupRequest", new XAttribute("USERID", "XXXXXXXXX"), new XElement("ZipCode", new XAttribute("ID", "0"), new XElement("Zip5", "43065"))); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://production.shippingapis.com/ShippingAPI.dll"); // parameters to post - other end expects API and XML parameters var postData = new...

Putting additional data to $routeProvider templateUrl request

javascript,angularjs,xmlhttprequest,angularjs-routing,ng-view

I'd suggest you to load those template at the run phase of angular. That will be putted inside $templateCache provider and when you request the same template for second time it will fetch directly from $templateCache itself. CODE //get the templates with headers in application run phase. app.run(['$templateCache', '$q', '$http',...

Multiple XMLHttpRequests At Once

javascript,php,xmlhttprequest

You could create a class that references a DOM element, and has a progressHandler method: var Pgb = function(elem) { this.elem = elem; var _this = this; this.progressHandler = function(event) { _this.elem.value = event.loaded/event.total * 100; } } Then create an instance of this class for each progress bar: var...

(CORS) How does the browser know when to do a pre-flight request

javascript,rest,dom,xmlhttprequest,cors

The browser will send a preflight request if: You add custom headers to your request You use a method other than GET, HEAD or POST You use POST with an unusual Content-Type. More details here: HTTP access control (CORS), Preflighted requests...

How to pass a parameter to CanvasJS returned from XMLHttpRequest?

javascript,ajax,json,xmlhttprequest,html5-canvas

Parse the JSON string to turn it into a JavaScript object. var toSend; try { toSend = JSON.parse(xmlhttp.responseText); } catch(e) { toSend = xmlhttp.response; } var chart = new CanvasJS.Chart('chartContainer', toSend); ...

XMLHttpRequest can't sent unicode chararcter as request header

javascript,html,xmlhttprequest

You can encode the data into like base64 and decode it on server. https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding...

XMLHttpRequest and C CGI…who sends back just one word

javascript,c,xmlhttprequest

Thanks a lot I solved using fgets! I didn't think about "mytext" is not formatted data. I would like to ask another small thing, why I don’t get any result when I change my C code in this: int main(void) { printf("Content-Type: text/plain;\n\n"); FILE * pFile; pFile = fopen ("sample.txt","w");...

Why can Chrome get file, but not Safari?

node.js,http,web,safari,xmlhttprequest

Try to put the plist resources under the same domain. You may need to check the cross domain problem XHR .

Not able to get Request-scoped attribute in Action through XMLHttpRequest

jquery,ajax,struts2,http-headers,xmlhttprequest

I guess the problem is that the AJAX call is ignoring your request-scoped attributes, since it creates a brand new XMLHttpRequest instead of a classic HttpRequest. Just add your attribute as hidden parameter in the form, unless you have reasons not to do so: <s:set var="receiverid" value="1" scope="request"/> <form action=""...

Firefox addon - how to use XMLHttpRequest in Chromeworker?

ajax,xmlhttprequest,firefox-addon

I modded my non-worker XHR function to work in ChromeWorker, but its not perfect as I don't know how to set loadFlags in the ChromeWorker version as in the ChromeWorker version doesnt have .channels, weird. But see this branch here: https://github.com/Noitidart/ChromeWorker/blob/xhr/myWorker.js My function there uses a promise scheme but you...

How to keep scope within an XHR request?

javascript,routing,scope,xmlhttprequest

The simplest (and very clear way) is to keep the reference to route's scope like this: var that = this; Also you can set the scope using .bind() and access request properties directly from reqest variable. And for your example (with bind helper function, to support old browsers): var bind...

Ajax / XMLHttpRequest tracking using javascript

javascript,html,ajax,xmlhttprequest,trace

Add at start of your script this: XMLHttpRequest.prototype.oldSend = XMLHttpRequest.prototype.send XMLHttpRequest.prototype.send = function (data) { // there you can log requests console.log("AJAX request was sent."); this.oldSend.call(this, data); } This creates copy of send method on XMLHttpRequest object and internal method replaces by method where you can log AJAX requests and...

XMLHttpRequest throwing InvalidSateError saying “Object state must be opened”

javascript,ajax,xmlhttprequest

The error is straight forward: Error in event handler for contextMenus: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED. You need to call .open(..) before setting the request headers. Given your code, I believe the best way would be to move the call to open...

jQuery.ajax() error with textStatus=error

javascript,jquery,ajax,xmlhttprequest

Found out it happens, whenever Reload is pressed in the browser, while the ajax request was still running. This post helped me implement a solution....

IE 10 pending XMLHttpRequest for 6 minutes and then answers the request (CRSF implementation with AngularJS)

javascript,angularjs,security,internet-explorer,xmlhttprequest

This may be a bug in IE related to your use of the HEAD method; see https://connect.microsoft.com/IE/feedback/details/1023203/xhr-readystate-done-delay-on-head-request Have you observed your network traffic with a proxy like Fiddler? If so, can you share a traffic capture?...

when will callback for synchronous xmlHttpRequest calls get executed?

javascript,xmlhttprequest

If the XHR is synchronous then the callbacks are executed before .send() returns. In other words before blablabla(). Browser DOM updates are asynchronous. Or rather, the redraws are asynchronous (DOM update/reflow can at times be synchronous but it won't draw to screen, just update data structures). So, even if...

Make use of unnamed array

javascript,json,xmlhttprequest

xml.responseText is an array, you need to access on the the good index before show label : var database = xml.responseText; console.log(database[0].label); // Add [0] because your example is an array of one element if you have more index refer to the edit If the response is a string, you...

d3.xhr - handling successful empty response

d3.js,xmlhttprequest

An empty response is invalid JSON (as opposed to an empty object or array, which would constitute valid json). This can be verified using http://jsonlint.com/ or in the console by running JSON.parse(''), which throws an error. So although the response is 200 ok, the load event — which should only...

How to update url via javascript in the XMLHTTPRequest

javascript,xmlhttprequest

You could do something like this: var requestNum = 0; function do_exercise () { var x = new XMLHttpRequest(); // adjust the GET URL to reflect the new n value and request as before x.open('GET', 'http://tmaserv.scem.uws.edu.au/chapters/?n=' + requestNum, true); x.onreadystatechange = function() { if (x.readyState == 4 && x.status ==200)...

How do I promisify native XHR?

javascript,xmlhttprequest,promise

I'm assuming you know how to make a native XHR request (you can brush up here and here) Since any browser that supports native promises will also support xhr.onload, we can skip all the onReadyStateChange tomfoolery. Let's take a step back and start with a basic XHR request function using...

How do you use pdf.js to get text content of client stored pdf?

javascript,xmlhttprequest,pdf.js

This doesn't really have anything to do with pdf.js per se. pdf.js just happens to be trying to load a file using XMLHttpRequest. The problem is that you gave pdf.js a path to a local file (c:\fakepath\vocab_list_15_8th_grade.pdf). Your web browser won't let a web page load the local file for...

is binary file(pdf, word, excel, ppt, mp3,…) download possible using XHR or fetch?

javascript,html5,browser,download,xmlhttprequest

The transfer encoding should be transparent to an application in a browser, don't worry about it. Below is a basic ajax file download solution, it uses XHR2, blobs and anchors with download properties. var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if (this.readyState == 4 && this.status == 200){ var...

How to beautify respond body of XHR (Ajax call) in Chrome browser?

ajax,google-chrome,google-chrome-extension,xmlhttprequest,google-chrome-devtools

you need a valid "application/json" content-type specified for chrome to give you the collapsible drop-down To see a tree view in recent versions of Chrome: Navigate to Developer Tools > Network > the given response > Preview ...

XHR OnLoad Promise blocking other OnLoad callbacks

javascript,asynchronous,xmlhttprequest,es6-promise

I think what you're asking here (with this horrible busy-waiting sleep() function that no-one should ever use in real code) is how come all the .then() functions take precedence over the onload events in the JS event loop? They do, and it's because promises run on a micro-task queue, which...

PHP returns JSON fine but JavaScript shows it is undefined in onload function

javascript,php,json,xmlhttprequest,undefined

Yeeeez I'm an idiot, I wrote this.reponseText instead of this.responseText. Sorry for troubles...

Scrapy crawler not processing XHR Request

python,web-scraping,xmlhttprequest,scrapy,scrape

If you inspect the "Load More" button, you would not find any indication of how the link to load more reviews is constructed. The idea behind is rather easy - the numbers after http://www.t3.com/more/reviews/latest/ suspiciously look like a timestamp of the last loaded article. Here is how you can get...

Google Analytics: XHR instead of pixel-tracking

javascript,google-analytics,xmlhttprequest

You can use the new navigator.sendBeacon method by setting the transport option to 'beacon'. Here's an example: ga('send', 'event', 'click', 'download-me', {transport: 'beacon'}); And here's the documentation: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#transport sendBeacon is a better option than XHR, and GA automatically handles the fallback for browsers that don't support it. If you really...

Maximum amount of simultaneous xhr requests?

javascript,xmlhttprequest

Apart sendRequestFunction being an implicit global and not your local GeoLocation property, you must not use a free variable in the asynchronous updatePosition method. Subsequent calls will overwrite the previous value, and when later your getCurrentPosition callbacks are invoked then each of them will call the same sendRequestFunction. Which is...

HTTP Post Request to web service . ERROR : Index was outside the bounds of the array

c#,multithreading,.net-4.0,xmlhttprequest

It happens because the expression () => function(files[x],p) is evaluated after the first inner loop is complete, and x is incremented in this loop. So you always get the out-of-range value of x=len. To solve this, you need to declare another local variable and assign value of x to it,...

How check file XML

xml,xsd,xml-parsing,xmlhttprequest,linq-to-xml

You say you get '3 warning but page is good'. What were the 3 warnings you got? Yes, you do need your doctype to validate effectively. Here is a version of your code that validates. It includes the Schema, and the encoding. It validates just fine. As far as the...

Firefox SDK Error “Image contains errors and cannot be displayed”

javascript,image,firefox,xmlhttprequest,add-on

Finally, I was able to detect the problem. For the XMLHttpRequest, I had to specify its response type as follows: xmlRequest.responseType = 'arraybuffer'; Then, the response was stored in a JavaScript ArrayBuffer, which I had to transform into a Uint8Array and then, store it into the stream. This solution applies...

Uncaught TypeError: Cannot read property '0' of undefined

javascript,jquery,json,xmlhttprequest

By default, XHR requests are asynchronous. That means that send starts them, but they complete later (which is why they have callbacks rather than return values). Just use obj within the callback. Side note: Your code is falling prey to The Horror of Implicit Globals (you never declare your xhr...

Make a HTTP request in your Controller - sails.js

javascript,node.js,xmlhttprequest,sails.js

Ok, I managed to solve this using another module 'request'. What I did: Install the module in your project, or globally (-g) using npm: npm install request And in you code you should have: var request = require('request'); request.get({ url: <your url> }, function(error, response, body) { if (error) {...

Edit and replay XHR chrome/firefox etc?

google-chrome,firefox,browser,xmlhttprequest

Chrome : One way to do that in Chrome could be to copy the request as cURL in the Network panel of the developer tools, and to replay it with your edits in a terminal, assuming you have the curl command. See capture : If you're looking for an "all-in-browser...

Upload pictures to the server which resizes them and compresses, and finally sends the result to the origin CDN? [closed]

javascript,node.js,image-processing,xmlhttprequest,image-uploading

The general approach: Send the image via AJAX or POST to the server. The server receives the image. As you are using Node.js, I found this library. Process the image and send it back to the client Why don't you post the codes that you have worked on so far?...

npm request vs. XMLHttpRequest for simple GET requests

javascript,node.js,request,xmlhttprequest

In a browser, XMLHttpRequest is already built in so you should only get some other library that builds on top of it if that library offers you particular features that you find useful and are worth the extra download. In the interest of keeping web pages as lean as possible,...

Agnostic scheme / protocol ajax call

ajax,http,https,xmlhttprequest,xdomainrequest

This approach definitely will not work: xhr.open("get", "//mydomain.com/api/v1/etc", true); as this will send the request on the relative url, as there is no protocol mention here. This approach works on XMLHttpRequest: xhr.open("get", window.location.protocol + "//mydomain.com/api/v1/etc", true); Important note that the XDomainRequest is obsolete and should not be used in your...

Scrapy follow pagination AJAX Request - POST

ajax,post,pagination,xmlhttprequest,scrapy

you can try this from scrapy.http import FormRequest from scrapy.selector import Selector # other imports class SpiderClass(Spider) # spider name and all page_incr = 1 pagination_url = 'http://www.pcguia.pt/wp-content/themes/flavor/functions/ajax.php' def parse(self, response): sel = Selector(response) if page_incr > 1: json_data = json.loads(response.body) sel = Selector(text=json_data.get('content', '')) # your code here #pagination...

Javascript return after XMLHTTPRequest()

javascript,xmlhttprequest

This is the programming paradigm that every new javascript developer has to deal with. Because of the asynchronous nature of javascript, functions tend not to pass values back via return statements, but instead the values are passed back via callback methods. function something(url) { getPage(url, function(temp) { console.log(temp); }); }...

Access to html basic protected image via SapUI5 & Cordova

android,cordova,xmlhttprequest,basic-authentication,sapui5

I found out that this appears to be a bug in the Android Webview. It is fixed in Android 5- This is fine for me and my example above works fine

How to make POST request in my app

javascript,angularjs,resources,xmlhttprequest

Pass 'id' object as first argument in save method: Product.save({"id":"12345"}, { name:'test name', quantity:'5' }) Working code: http://jsfiddle.net/7rx5fqx2/1/...

ExpressJS : req is undefined

javascript,node.js,post,express,xmlhttprequest

I found the solution. When you want to get the body of POST request with express use : app.use(express.bodyParser()); Then you can do : var urlToAdd = req.body.url; ...

Unable to override XMLHttpRequest using pageMod (Firefox addon)

javascript,firefox,xmlhttprequest,firefox-addon

PageMod scripts run in a sandbox that have a different view on objects (aka. xrays). Depending on how exactly you define them a content page cannot either access those objects or get security exceptions if it tries to invoke functions. Accessing the unsafeWindow is the correct approach, but you still...

Getting Json data from text file in AngularJS

javascript,json,angularjs,text,xmlhttprequest

You are missing to define $http as a parameter app.controller( "customersController", function( $scope, $window, $http) { Also make sure you are testing in a web server. You cann't make ajax request from file:// protocol Also change your request from POST to GET and it should work fine. Here is a...

ObtaI n url of page which fired ajax request in ajax view

jquery,ajax,django,xmlhttprequest

You could use request.META.get('HTTP_REFERER') in the view and extract the info from there.

XMLHttpRequest to Restivus API

javascript,meteor,xmlhttprequest,cross-domain,cors

The answer is more than obvious after finding out. I just need to to set the options method in the restivus route to authRequired: false. You cannot send a complete header with credentials when doing a preflight. Now I am first doing the preflight and then sending the real post.

How to send a JSON data object to the server using Javascript XMLHttpRequest?

javascript,php,ajax,json,xmlhttprequest

PHP will not populate $_POST for an application/json request. (You aren't actually sending a proper JSON request because you forgot to set the Content-Type header on your XHR object, but the data will be invalid in any other format so the end result is the same.) It will only do...

Double issue with “this” scope in xmlhttprequest javascript

javascript,ajax,asynchronous,callback,xmlhttprequest

It is hard to follow the objective of your code, but the main thing you need to learn in Javascript is that the value of this within a function is controlled by how the function is called. This is confusing in Javascript until you fully grok that all that matters...

XMLHttpRequest returns wrongly encoded characters

javascript,pdf,utf-8,character-encoding,xmlhttprequest

XMLHttpRequest's default response type is text, but here one is actually dealing with binary data. Eric Bidelman describes how to work with it. The solution to the problem is to read the data as a Blob, then to extract the data from the blob and plug it into hash.update(..., 'binary'):...

Can I use XHR to load a local file (from SD card) on android?

javascript,cordova,xmlhttprequest

After a lot of testing I can say with utmost confidence that XHR can be used to load local files (from SD card) without any particular changes in project configuration, however... XHR cannot be used in the phonegap development app (other than for loading internal files from the app). Those...

HTTP Post Rails 4 Issue

rest,ruby-on-rails-4,xmlhttprequest,http-post,net-http

My guess is that you have configured your email parsing service to POST the data to a URL which is only accessible from your local system, for instance a pow.cx style ".dev" URL. The reason this works using your test utility is I'm assuming the test client is also on...

Change Response from HTTP Request sent by a program

networking,http-headers,xmlhttprequest,fiddler,packet-sniffers

Definitely - Fiddler allows you to modify requests and responses by adding rules to FiddlerScript. Citing Fiddler documentation: To make custom changes to web requests and responses, use FiddlerScript to add rules to Fiddler's OnBeforeRequest or OnBeforeResponse function. Which function is appropriate depends on the objects your code uses: OnBeforeRequest...

On slow network previous Ajax request gets cancelled by the subsequent

javascript,ajax,xmlhttprequest

You should use a local variable to hold the XMLHttpRequest. Since you're using a global variable, the callback function always refers to the second AJAX request that was sent. So change: xhr = new XMLHttpRequest(); to: var xhr = new XMLHttpRequest(); Then each callback funtion will be a closure that...

error: Bad content type. Please use multipart

javascript,angularjs,file-upload,xmlhttprequest,google-cloud-storage

The problem is that the endpoint you're using is for multipart uploads, but not FORM-based multipart uploads. If you set your Content-Type to "multipart/related" instead of "multipart/form-data", you should be able to proceed. A multipart upload to that endpoint, "www.googleapis.com/upload/storage/etc?uploadType=multipart", expects a multipart message with exactly two parts, the first...

Multipart file upload with Spring: NoSuchMethodException: …CommonsMultipartFile.()

java,spring,maven,xmlhttprequest

Your problem could be in servlet config. Be sure to declare CommonsMultipartResolver bean in serlvet configuration. Here you are an example in xml config: <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- <property name="maxUploadSize"> <value>your preferred size</value> </property> --> </bean> and here one in java config: @Bean public CommonsMultipartResolver multipartResolver() { return new CommonsMultipartResolver();...

Is there a way to get the progress info when download file/web page in XMLHttpRequest

javascript,xmlhttprequest

http.onprogress= function(){ //event.loaded and event.total usage } Read more about XMLHttpRequest and oprogress here...XHR...

Can CDNs handle base64 encoded data?

image-processing,upload,xmlhttprequest,base64,cdn

CDNs usually do not provide such uploading service for client side, so you can not do it in this way.

jQuery AJAX dataparam passing issue in Blackberry

jquery,ajax,blackberry,xmlhttprequest

I found out the rootcause of the issue. By default all browsers convert JSON object to serialized representation before submitting XMLHTTPREQUEST. But it is failing only in blackberry devices. So before submitting jQueryAJAX post method, dataParam needs to be converted as URLString by using $.param method. var fomrValues = $("form[name="...

Apiary Invalid Header

javascript,xmlhttprequest,apiary.io,apiary

It looks like XMLHttpRequest changes the charset to uppercase UTF-8 in this case when sending the request. When trying the request through the Apiary.io documentation, it keeps the charset for content type to lowercase utf-8 and says the request is valid. When I copy/paste the code example into Chrome's console...

Why does the jquery ajax documentation mean when it says “For backward compatibility with XMLHttpRequest”

jquery,ajax,xmlhttprequest,jqxhr

Why is this "backwards compatibility"? Because a long time ago, jQuery's ajax method returned the XMLHttpRequest object directly. And if so, what is the proper way to access the HTTP response if not through the jqXHR object? Through the arguments to the callback function success and/or the promise's done....