Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces - ajax

I am getting the below JavaScript error when I'm trying to access the application.
Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces
The browser is loading, but page is not displayed.
How is this caused and how can I solve it?

Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces
This will happen when the server returned a HTML document while the browser tried to download the mentioned JavaScript file (which is necessary for a.o. the functioning of <h:commandLink> and <f:ajax> in JSF 2.x).
You probably already know that HTML documents usually begin with a < and a JavaScript file absolutely not. Inspecting the HTTP traffic monitor and the actual HTML response should give clues as to what exactly it returned. Press F12 in Chrome/Firefox23+/IE9+ to see it. Perhaps it's a HTTP 4xx error? 401 unauthorized? Or 403 forbidden?
That can in turn happen if your (homegrown) security/login framework is badly configured. This problem is in turn not related to JSF itself. Basically, you need to fix/reconfigure it allow requests on /javax.faces.resource/*.
See also:
JSF page style missing when using login filter
Exclude css & image resources in web.xml Security Constraint
HTTP Status 403 - Access to the requested resource has been denied (CSS blocked?)

Related

AEM Magento Integration sample project ,cart icon is missing and the below error is coming in the console

The integration with magento was done and the categories and products are showing up. However, the shopping cart icon is missing and the below errors were observed :
POST http://localhost:4502/magento/graphql 403 (Forbidden) (anonymous) # react-components.js:16
react-components.js:16 Error: Network error: Unexpected token < in JSON at position 0
react-components.js:16 Uncaught (in promise) Error: Network error: Unexpected token < in JSON at position 0
Cart will not be even visible until and unless you do not setup a dispatcher as shown here in this video. The mini cart is actually a react component which directly communicates with Back-end Magento and to avoid CORS issue you have to set up proxy through a Dispatcher.

XHR to same domain being blocked

I'm having a pretty weird problem with CORS on a webapp I'm trying to make
I'm using Servlets (Tomcat8.0) for the backend. It's a school project, so I can't use a framework
A GET request to http://localhost:8080/FileBox/dashboard
returns a JSON payload( plain json, not jsonp,which I could use, but its the same domain). I'm using ajax to make the XHR, but it's being blocked by chrome as CORS
Should this be happening, since I'm making the XHR from the same domain(host+port)
'localhost:8080/FileBox/dashboard.jsp'
to
'localhost:8080/FileBox/dashboard'
Please, and thank you for the help!
You aren't making a request to http://localhost:8080/FileBox/dashboard. The error message says you are making a cross-origin request using an unsupported scheme and that http is a supported scheme.
Presumably you have made the two mistakes of:
Getting the URL wrong
You should be using a relative URL:
/FileBox/dashboard
but are trying to use an absolute URL:
http://localhost:8080/FileBox/dashboard
but have typed it wrong and are actually requesting
localhost:8080/FileBox/dashboard
Not loading the page over HTTP to start with
Possibly by double clicking the file in your system file manager, you have bypassed your HTTP server and are loading something like file:///c:/users/you/yourproject/index.html
Combined with the previous mistake, you end up trying to request file:///c:/users/you/yourproject/localhost:8080/FileBox/dashboard, with Ajax and get a security violation.
Solution
Fix the URL to be a proper relative URL
Point your browser at http://localhost:8080 instead of double clicking files in your file manager

Unintuitive behaviour of Poltergeist's `page.status_code`

We have a feature:
#smoke #acceptance
Scenario: Home page is available
When I visit the home page url
Then I expect no error code
With the final line implemented as:
Then(/^I expect no error code$/) do
expect(page.status_code).to eq 200
end
This sometimes fails. When debugging we've found the following:
the page itself always responds with 200
however, one resource within the page sometimes responds with 204
(which causes the test to fail)
This suggests that page.status_code does not equal the status code of the actual URL requested, but could be set to the status code of any (or presumably the last?) of the resources requested by the page.
Is this the correct explanation, and is it the expected behaviour of page.status_code?
Notes:
I realise that 204 could be construed as success, but this is not the
focus of this issue
status_code returns the result of the last request that triggered the phantomjs onLoadStarted callback - this should be the page, or potentially ajax requests initiated by the page -- it should not be assets being loaded directly as resources on the page (img, javascripts, css, etc). If it is a dependent asset then phantomjs has an issue and should be reported with reproducible example on that project. What type of request is reporting with a 204 response? If it's an ajax request then it is as expected - if not then its a bug in phantomjs. Note: checking response codes when using Capybara really is an anti-pattern, and you should generally stick to testing visible changes on the page.

Fine Uploader Response Error OnComplete In IE 10

Manual Uploader Working Fine with All Browser expect IE 10, i am not getting correct Response From the Server it is Showing on onComplete "No Valid message Received from Loaded iframe For i frame Name 1_97604 cec......".
File are uploading into the cloudbees server but not getting correct Response From the server.
In case of Other browser i am getting Response.success = true, but For IE 10 its undefined, how to handle this error. Please help me Out for this.
Regards
Yogesh
You aren't using IE10 if that is the message you are seeing. Most likely, you are using IE9 or older. The message you are seeing is logged by the form uploader, which is never used if you are uploading via IE10. Perhaps you are running IE10 in IE9 or IE8 mode. Either way, the message indicates that you are working in a cross-origin environment (you have set the cors.expected option to true) but are not returning the proper response from your server. Note that older browsers, such as IE9 and older, utilize form submits, targeting an iframe, to upload files. In order to access the contents of that cross-origin iframe, the iframe needs to post a message containing the server response to Fine Uploader's window. This is all very easy to do, all you need to do is return a text/html response from your server that looks something like this:
"{\"success\": true, \"uuid\": \"9da17ad5-ad6a-40cd-81b5-226e837db45b\"}<script src=\"http://<YOUR_SERVER_DOMAIN>/iframe.xss.response-<VERSION>.js</script>.js\"></script>"
The javascript file mentioned in the script tag is provided in the Fine Uploader released zip file. It does all of the work for you. You must return a JSON response before the script tag, as illustrated above, and the response must include the UUID of the associated file.
You should read about cross-origin support either in the associated blog post.

xhrPost : from an http view to an https url

using Dojo, is it possible to make an Ajax call using xhrPost from an HTTP view to a HTTPS url ?
The url must be HTTPS (as defined in Struts).
If I simply set "MyCommand" as the 'url' parameter of the xhrGet, I get a 302 error code.
If I transform "MyCommand" using javascript to something like "https://......./servlet/MyCommand" I see the following error in Firebug : "uncaught exception: Permission denied to call method XMLHttpRequest.open".
I'm stuck using both approaches, the only solution I found is to remove the "https" clause in the struts configuration file, and of course this is not a correct solution :)
Thanks for any help.
Best regards,
Nils
connection to https from http involves a different port of the target. This violates the same-origin policy which should be enforced by the browser to the running javascript code.
It should work with an iframe..
dojo.io.iframe encapsulates this behaviour for you
http://docs.dojocampus.org/dojo/io/iframe
If your server responds with a redirect to a non-ssl (correctly to same-origin) page you should be able to read the response (because the iframe is now in the same-origin).

Resources