Custom 404 page causing sub file to not load javascript - javascript

I am not 100% sure if this is my issue, but this is what I have narrowed it down to. I created a sub folder and added a file to it. When I open up this page's console, I get the following error.
Error:
Uncaught SyntaxError: Unexpected token < 404custom:1
Which is just this:
<!DOCTYPE html>
My javascript files will not load because of this. I call my custom 404 page in my .htaccess file, like this:
ErrorDocument 404 http://www.website.com/404custom
The page's destination is fine and the new sub file loads. Is the way I am calling the 404 page wrong and not able to work with a sub-folder? I do not get the error in any of my other files in the root of the site.

ErrorDocument 404 http://www.website.com/404custom
Your custom error document should be defined like:
ErrorDocument 404 /404custom.php
If you specify an absolute URL for the ErrorDocument then it will trigger an external redirect, you will lose all the error information and your system then processes the error document URL, which you then need to rewrite to append the .php extension. All of that is unnecessary and should be avoided.
If it's all on the one server then the error document should be triggered with an internal subrequest. The user never sees /404custom.php, only the URL that triggered the error in the first place.
You also need to make sure that your error documents are excluded from any rewrites you might already be doing (like appending file extensions etc.)

Related

My php script return a 403 error whene i call him

I have a little problem with PHP:
On my site, I call the PHP script with the fetch method in javascript to dynamically record log files or to list the files in a folder with the PHP blob() function.
My problem is that locally everything works fine, but once on the server, I get the following error with a 403 code:
Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I tried to put the rules to 777 on the files, nothing to change. I also tried to delete the .htaccess (in case a rule disturbs), but no result.
I dry a bit, and I don't know what to try :/
If you have an idea, I would like to know her!
Thanks for your time :)
EDIT :
After a lot of tests, I discovered that the same code works perfectly on another server... so it's probably the configuration of the server I need to change, but what? I don't know exactly, ^^.

Uncaught SyntaxError: Unexpected token < on each js file that invoked in the index html

I am using mean stack to build a website, when testing, chrome returns the error like:
Uncaught SyntaxError: Unexpected token < angular.js:1.
I don't know what's wrong and what should i do.
Here is the directory of my app:
E-study
-client
-app
-components
-all the libraries are here.
-index.html
-controllers.js
-node_modules
-server
-config
-server.js
And I run the server in E-study like :node server/config/server.js
The scripts in the index.html is<script src="client/components/angular/angular.js"></script>
Just don't know why all the js files are changed to index.html when open in the browser.
open up those library files and see if there are some extra symbol < probably you will find it in the beginning.. if still not able to fix... simply download the fresh library (if those are libraries) from the internet and try again.
make sure that you don't put <script> </script> tags in the included .js files. that is an incorrect syntax for script files.
also make sure you are providing the correct path??? providing incorrect path can return a builtin customized error page. which is html. may be that is the source of error because returned page is HTML which is most likely going to start with a < symbol. and offcourse not a js file.
to ensure that the incorrect path is the issue just copy the path you included in the code and and paste into your favorite browsers url bar and hit enter. if you are not getting the script in plain text.. then it means you are not providing the correct path.
and if it is return a customized error page like .. 404 not found then probably it is returning the html and this is where the error is coming from.
In external js files, which you refer in some other files, don't use <script>..</script> tag.
For express server try to set the static path to entire project folder.It worked for me
app.use(express.static(__dirname ));
Could be a ReCaptcha bot checker type thing intercepting requests for JS files and serving up an HTML page instead, which is invalid HTML so it throws the < is invalid message error.
I know siteground specifically has issues with this intercepting CDN routed traffic.
Check with the host to remove this issue, in this case it's their anti-bot security setup. This has remedied these issues with Siteground for me.

I can see a webpage on a local computer, but after uploading it the pictures don't appear

I try to use a template provided here:
http://themes.alessioatzeni.com/html/brushed/
Then, I downloaded the basic files and modified them for my purpose. It was OK. I didn't have any problem to see the pages on my computer. I tested it with Edge, Chrome, and Fire Fox. Everything showed it very well. Then, I uploaded all the files on my website:
http://hirophysics.com/japaneseusedcar/bahama-used-car.html
Then, there is no picture on the slider and also I cannot find the right and left arrows on the menu bar...
I checked if all the file are uploaded. I found everything on the server. I didn't use any foreign language...
Would someone possibly advise me where the problem is hidden?
Thank you very much!
Hiro
I would go with the typical reason: wrong url to a resource. Often, when you are launching the page locally you get a bit different url than on the server. And your errors show exactly that error
Failed to load resource: the server responded with a status of 404 (Not Found)
So check again, if the URL you provided is correct. And as I said, the URL might be different between local and server eventho folder looks exactly the same.
http://hirophysics.com/japaneseusedcar/_include/img/logo.png Failed to load resource: the server responded with a status of 404 (Not Found)
Try to use your resources with additional ".." before directory where they are (for example you have
_include/img/logo.png so try ../_include/img/logo.png)

Flash360 rotator giving Error 2032 on server

I have a flash rotators for a website i am doing for a client.
I am able to view and use them if i load them off my computer.
But as soon as i load them on to any of my servers and try to access them i am presented with an IO error 2032
Now i know this means it cant find the files it needs to load so i then changed all the links to absolutes when it was calling for the necessary files and i still get the error.
I have also checked all folder permissions and their all good.
I am at a loss to wht maybe the problem.
here is a link were i just put all the rotators up to view
http://honeyword.mybigcommerce.com/pages/Clickers
file structure
Mainfolder
Viewer
_html files (for each product)
_swfobject21.js
_expressInstall.swf
_ImageRotator.swf
_Products
__Folders(producname)
____config.xml
____Images
_____.png
any help would be appreciated.
thank you
It seems to be an error related to file or folder permissions: I get a 403 Forbidden error page when accessing the file in the error message directly (I copied the filename from the first of the error messages below the "checking..." field and just pasted it in a new browser window).

My lightbox script won't load

Hey I'm trying to get this lightbox script to work on a client site but I get this error '$ is not defined', I'm not well with JS so i was wondering if i could get some help, heres the site - http://www.petconnection.com/blog/.
Thanks, Antonio.
Here's the problem:
/res/javascript/lightbox/jquery.lightbox-0.5.js
Failed to load resource: the server responded with a status of 404 (Not Found)
/res/javascript/jquery/jquery-1.4.2.min.js
Failed to load resource: the server responded with a status of 404 (Not Found)
The page is trying to retrieve the JavaScript file that defines jQuery (hence $) but the server is replying with a 404 error. Either it's requesting the wrong URL, or the file has been deleted from the server — perhaps replaced by a new version of jQuery (1.4.2 is pretty old at this point, we're on to 1.5).
The order of those messages also indicates that you're (trying to) load the the lightbox script before the jQuery script. This is bad juju. Lightbox depends on jQuery, so you've got to load jQuery first.
Antonio, it doesn't look like either of your scripts are loading properly. Try linking directly (instead of relative links) or just double check the links you currently have.

Categories

Resources