I try to send a request to my server via GET, but qooxdoo sends request as OPTIONS. Is any way to change this behaviour?
I try to use qx.data.store.Json (url) and qx.io.remote.Request (url, "GET", type) but result is same in both cases.
My version of qooxdoo is 1.0.1, browsers are FF 3.5.6 and Chromium 5.0.361.
It is most likely a problem due to cross browser restrictions. Give the JSONP store a try and deliver your data as JSONP to get rid of that problem.
I think this is because I try to send cross-domain request from file:/// to http://.
If I deploy a test application to server - it works fine.
Related
How does one take an HTTP request and redirect it to proxy (on an ad-hoc basis, assuming browser is on no-proxy)?
For example: I want to access http://www.stackoverflow.com/questions.
In terms of the API, this request would look like this:
Method: Get
Url: http://www.stackoverflow.com/questions
Headers
Host: www.stackoverflow.com
More-Headers: More-Values
If I have to send the same request to proxy, I need to add a proxy authorization header. I also need to change the URL to http://www.myproxy.com. How do I specify the URL of the website that I want to visit?
In terms of actual coding:
In onBeforeRequest callBack- I change the URL by returning {redirectUrl: https://www.myproxy.com}
In onBeforeSendHeaders callBack- I add the proxy auth header. I leave the Host header as is.
Where and how do I mention the URL of the target website I need content from?
The webRequest API won't let you do what you're asking, you need the browser to handle the proxying. The proxy API is meant to provide a way to do this, it is implemented in Chrome and is currently (August 2016) being implemented in Firefox (tracking bug is https://bugzilla.mozilla.org/show_bug.cgi?id=1283639).
Is there a way to get response status when doing JSONP request. I mean, can I see if it was a successful request 200 OK, or not found 404, or not available, etc. ?
ALTERNATIVELY: Maybe there is a way to try to load .js file using new Image() object, i.e. assuming it is an image and then see the response status? Or try to load even something completely different?
Is there any JavaScript cross-domain way to check if a resource is available or 404 unavailable?
May be that library can be helpful:
https://github.com/jaubourg/jquery-jsonp
I'm trying to do a CORS XHR post w/ credentials. It works great in Chrome, but not in Firefox. The cookies are not present in the pre-flight request headers, and so I'm seeing a 302. This works perfectly in Chrome, as cookies are in the pre-flight request headers and the subsequent POST goes through.
Why wouldn't this work in FF? What am I missing?
// assume url, boundEventHandler and uploadData are defined, as this definitely works in Chrome
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.addEventListener ("readystatechange", boundEventHandler, false);
xhr.withCredentials = true; // FWIW, I've also tried the string 'true'
xhr.send(uploadData);
Any ideas? I see some posts that say I can proxy the request on the server side, but I'd prefer to get this working in accordance w/ the CORS spec.
Thanks!
Per spec at https://www.w3.org/TR/cors/#resource-preflight-requests the preflight request never includes cookies. Specifically, the spec says:
Exclude user credentials.
and that links to https://www.w3.org/TR/cors/#user-credentials which says:
The term user credentials for the purposes of this specification means
cookies, HTTP authentication, and client-side SSL (...).
That said, the code snippet you quote above shouldn't involve a preflight at all: there are no upload event listeners, the method is as simple method, and there are no author headers set. So if you're really seeing a preflight request, the first question is why that's happening. Do you have any extensions in Firefox that might be munging your XMLHttpRequest object?
Now Chromium(the 4th of July 2014) doesn't sent cookie with a preflight request.
https://code.google.com/p/chromium/issues/detail?id=377541
I use plupload with html5. I try to upload file from cross-domain site. File uploaded ( I add header Access-Control-Allow-Origin * for server ), but response from server is empty. How to use upload in this case ? For example In jquery I simple select method jsonp.
plupload also sets a Content-Type header, so your server must also respond with Access-Control-Allow-Headers: Content-Type or else the OPTIONS request for CORS will fail.
If you need to debug this, the Web Inspector in Google Chrome does a fairly good job at pointing out which was the cause for your CORS request to fail.
New here. I've searched quite a bit for a working solution to my problem, but even though I have found posts with promising titles, none of the solutions have worked.
I am deploying an MVC2 web app to a client's server.
I did my development on Win2k8 Server, but they are running Win2k3 sever.
The app's only purpose is to receive some record ID information as HTTP parameters, check in the database for the status of the given record or records, and then return the status information as a simple string such as "Completed" or "Incomplete" in JSON format.
This getJSON code works fine in the development environment.
Inexplicably to me, on the client's server, the getJSON request receives a null response from the application.
There is no cross-domain action AFAIK... the result is the same from the client's server or from my machine via VPN.
In the MVC model's Json code, a common solution for people is to add the "JsonRequestBehavior.AllowGet" attribute to the Json result being returned. I did this long before trying to deploy it, and as I said, it has worked fine in the dev environment.
Using Firebug, I have watched the same request URL get sent to both my local server and the client server - the response headers from both servers are the same, but the response content from my server is shown as:
{"Result":"No Data"}
Which is what I want.
There is literally no content shown in the response from the client's server..? But the request gets an HTTP 200 code and is recorded as a success in the reponse's status attribute.
The response header content type in both situations is "application/json"
But wait, there is more!
If I manually enter the request to each server in the Firefox nav bar, and hit enter, in both cases it responds with:
{"Result":"No Data"}
Which is what I want. So why can I get the result I want from the MVC app on the client's server only when I hand-enter the request URL in Firefox, but not from the Javascript code?
I have tried forcing different output content types ... using the jQuery ajaxSetup method...
$.ajaxSetup({
async: false,
dataType: 'text'
});
or
$.ajaxSetup({
async: false,
dataType: 'html'
});
and again wtih 'script', and 'json'. I also tried the conversion options such as 'text json' or 'html json' or 'json text' and so forth.
Some of the posts I'm reading, and my gut feeling, though, suggest the problem is not the jQuery code making the request that is at fault... I don't see how the same jQuery request point to a different server running the same app would suddenly cause that server to send back a 'null' value.
By null, I want to be clear... I mean nothing is sent. There is no {} or {null} or any sign of JSON... just blank whiteness of non-existence :P
Even if nobody knows the answer, I would love some input perhaps suggesting where I should focus my sleuthing ... client or server?
If the problem is the server, it seems hard to really know that the MVC stuff is running 100% on the IIS6 server, but in general it seems to work. I have a different MVC app running on the client server which responds to the virtual paths, and generally runs the same as on dev machine.
I have found one thing ... the request headers are somewhat different? The Request Headers sent to the IIS7 setup include an "X-Requested-With: XMLHttpRequest", "referrer" , and "cookie" field/value.
I could guess that the lack of the "X-requested-with: XMLHttpRequest" in the IIS6 request headers is a clue, but I do not see then how the same javascript code pointing at a different server can generate different request headers itself. So how else are those being generated?
The javascript is embedded in an ASP.NET page, btw.
Oooh.. frustration!
Thanks for any input.
Odd Progress ... apparently there is some sort of issue with IIS6 handling the query. Although I have not payed any attention to JSONP, a post elsewhere suggested that sometimes use the "&callback=?" parameter at the end of a .getJSON request URL would force it into GET mode and that worked frequently for problems getting data from the server. So I did that... and it did work, sort of. The proper {"Result":"No Data"} was returned in response to the request... which seems good. However, the way that the JSONP callback works, it generates its own script to do the calling and fetching and interpreting of the incoming JSON. In this case, it interprets the JSON to need a label which it does not have, thus an error is thrown "invalid label" ... there must be some way to hack things to just deliver the JSON, but the whole required use of JSONP callbacks suggests that the server configuration is wrong, right? Or why does it work without JSONP for IIS7 and not IIS6?
Despite my not liking the callback JSONP solution, it appears to work ok. The error is still returned about an invalid label, but that does not appear to stop the remaining javascript from running... and so the application is working with IIS6 now. I have not tested the fix of using the callbacks and JSONP against IIS7 yet, but I expect it will work well enough.
Here is a link to the discussion that lead me to my current solution. I do still hope to find a more elegant solution, however.
NeoWin.net
Are you certain that your App Extension Mappings are set up correct?
Follow this article for running MVC2 on IIS6 and ensure all the different configurations have been done, that's probably the first step before going further and investigating specifics.
I'm really inclined to believe it's related to HTTP Verbs.