I'm trying to setup my laptop to be able to test java scripts, in particular in need to be able to make AJAX calls to .csv/.tsv files.
To do this I have setup xampp and moved my files to the xampp directory. Will I need to do anything else (e.g. configuration) to be able to open the .html file saved in the xampp directory and have it be able to make AJAX calls. When I do this I still get the usual "same origin" error.
I know that the code should work as I am trying to reproduce one of the d3 examples to see if the server works.
Would anyone be able to point out what I'm doing wrong?
Related
I have a web application that triggers actions at the server side which result in the generation of data files.
The so generated data files are stored within a folder at drive different from the one where the Web application is.
What I tried so far is to create a shortcut (Windows Server) next to the Index.html, where the shortcut points to the folder at the second drive.
This solution does not appear to work:
If I copy the data file to the same folder where the Index.html file is and enter navigate to the URL httm://127.0.0.1:324324/Data_File.xlsx I get the file downloaded.
If I enter httm://127.0.0.1:324324/MyShortcut/Data_File.xlsx (where MyShortcut points to a folder in drive D) the attempt fails.
How can I achieve this?
The need to access files in the different drive is essential.
You need to configure your server to serve that folder under different location. The only reason you are able to see your app and access that folder is cause server is set up to serve it ATM, not because you are making the right calls from the front or cause the front is asking nicely.
Don't know what Windows server version you are using and IIS version that goes on it, or are you even using IIS (you most probably do) but depending on what you use you need to do something in a lines of this:
IIS7 config
What you probably wanna do is create virtual folder in IIS. Try looking into it, then if you fail ask a question with proper tags according where are you stuck.
I don't see how this is connected to front-end at all so front end tags wont get you far.
EDIT:
Oh, in that case get a second file server running for that folder? This should be the fastest way, use what you can from this list: list
I need some help. I am working on the web page based on prestashop.
I've done everything on the local server on my machine.
Everything worked correctly. I decided to public the page so I move to the server.
When I open the page with chrome or other browser It looks very bad.
I checked the console and I've got some errors like this:
boston-armatura.pl/:26
GET http://boston-armatura.pl/new/themes/boston/assets/css/mystyle.css
boston-armatura.pl/:28
GET http://boston-armatura.pl/new/themes/boston//assets/css/theme.css
There is quite a long list.
I tried to change privileges.
I am also sure that the path is correct.
what might be the problem?
The server is not allowing you to access those files maybe due to some configuration you might have made on your .htaccess(webconfig) file.
And that's why it is giving a 403 error.
If there are errors, edit your .htaccess file which this:
Options -Indexes
This will deny access to just the directories and no js, css and any other files.
I was working on a Angular JS project. Basically it is a purchased theme with Angular JS, HTML, Bootstrap etc. when i tried to run it directly on browser it is broken. but when i run the same in my local server, it works fine.
I understand the importance of setting up a local server when we work on a project with server side language like PHP, .NET. what i am really confused is, why do we need to set up local server to run javascript or any javascript frame work?
Thanks in Advance.
I would like to do these examples by access "file:///C:/TempProjects/GameOfCards/index.html#/" on local computer, but most browsers cannot access these files on local computer do to Cross Origin issues. Here a StackOverflow question and answer that describes this issue: Cross origin requests(CORS) are only supported for HTTP but it’s not cross-domain. So we need a web server
There is another way, by adding a switch in your browser(chrome in this case)-
--allow-file-access-from-files
But, I suggest, running a simple server is the best way of working with things. Hope it helps. Happy Coding.
it happened for me . and I got that , when you run a js project directly , the address of some dependencies will change . for example your index is in c://www directory . if you want to open a html file which it's address in routing is in
c://www/public/... the routing would be different . because when run on a server the www directory is running and your home directory is that . but when you run directly, your home directory is where your index file is ...
I am trying to load some content inside a div #display. I have read many questions regarding this matter here, but still I have been unable to get it working. The alert function which I have just added for testing purpose works without any problem.
Here is what I have tried
$(document).ready(function(){
$('#townships').click(function() {
$('#display').load("helloworld.html");
alert("Hi");
});
});
I am trying this offline. The helloworld.html file is in the same folder with the homepage file.
I am trying this offline
I believe this is your problem. AJAX requests to the local filesystem will be blocked by the browsers' security settings.
You need to run it under a webserver, either on your local machine, such as WAMP/LAMP/IIS or on a remote machine.
You can not do AJAX request without loading files from some server. Doing it by loading files from file system won't work because of SAME ORIGIN policy. Since there is no domain to compare to the AJAX requests fail. You can see the exception while doing it in Chrome.
This is relevant
AJAX code do not run locally
You should put your html file in a web server. If you have python installed, you can just type
python -m SimpleHTTPServer [port]``
In order to have a rapid web server in your working directory.
I'm using w3schools to try to understand how simple AJAX requests work and I came across this exercise page:
http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_ajax_load
I thought it was a simple example of an ajax request, so I copied and pasted the code into a plain ajax.htm file and copied and pasted the txt file it refers to:
http://www.w3schools.com/jquery/demo_test.txt
...and saved it as demo_test.txt file it refers to and saved them both in the same folder. (Keep in mind, I have an Apache server that processes PHP locally with no problem, so I would think a simple request like this would work on my local machine).
However when I click the button locally I get nothing. Then, when I upload the files to a different server (a "web host") suddenly it works.
So, this works on a webhost and it works at w3schools but it doesn't work locally on my machine in my root folder (where php works without a problem).
I would prefer to not have to upload my code before being able to test whether it works and would rather be able to process everything locally, like I do with PHP. Is it possible to do this locally or can I only make these requests remotely from my web host?
Why is my machine not processing this code? Any help would be appreciated. Thanks.
There are a lot of reasons you might not be able to load the file locally, but most will have to do with how you're serving the files. If you're using file:// you're going to run into problems; you said you have an Apache server, but didn't mention whether you were actually serving this site from it.
Have you checked to make sure that the route you're loading via your AJAX call is actually loading properly? E.g. if the ajax file is at your web root (http://local.site/ajax.html) and so is your txt file (http://local.site/demo_test.txt).
In this situation you can also always check your browser's Javascript console to see if you get any errors or if the files are actually loaded correctly. Depending on how you're serving and accessing the various files, you might be getting CORS errors as well.
The simplest solution is to make sure you're running on a local webserver (your Apache) instead of directly viewing files.