Use a localhost file on a url API - javascript - javascript

Can we use a file who is stored on a localhost server, with an URL Api ??
The path for my localhost file is : http://localhost/DPGF/dpgf.xls
The API url link is :
https://sheet.zoho.com/sheet/view.do?url=http://link.to/file.xls&name=newName
And i'm trying to do this :
https://sheet.zoho.com/sheet/view.do?url=http://localhost/DPGF/dpgf.xls&name=newName
But this doesn't work for me.. so i don't know why or just that the API only supports real file links :(

First of all localhost is only reachable from your own machine, server at sheet.zoho.com could not possibly have access to it, and even if it did there would still be problems with cross-origin access to the page.

Related

How can my CORS Proxy Server load a url with various parameters (making an chrome extension on manifest V2)

My problem is that I need to bypass CORS and I am trying to receive information from:
https://steamcommunity.com/market/search/render/?query=
&start=0
&count=100
&search_descriptions=0
&sort_column=price&sort_dir=desc
&appid=753&category_753_item_class[]=tag_item_class_2
&category_753_cardborder[]=tag_cardborder_0
&norender=1
&category_753_Game[]=tag_app_XXXX
&category_753_Game[]=tag_app_YYYYY
&category_753_Game[]=tag_app_ZZZZ
but, when I use my Proxy cors server like that (hosted on render):
https://ttetetes.onrender.com/?url=https://steamcommunity.com/market/search/render/?query=&......
The page only uses only up the the first &category_753_Game[]= parameter of the url both to receive information with fetch or to load in the browser. This doesn't happen if I don't use the proxy, but the latter is necessary for my extension to work
This is the code of my cors proxy server created in python, I base it on a github project and modifications were made to try to make it work for my requirements:
app.py on github
I don't have too much knowledge on this code, I'm sorry. I'm just trying to make an extension that I devise in javascript work
This is the modified code with some tweaks,
This is the original code of the CorsProxyServer:
Original CorsProxyServer
Some helpful AI chat and I made some modifications and got some url parameters to work, but just the first ones

(Web Server) Can't find a folder JavaScript script is successfully reaching

I'm working with an HTML file that sends data using AJAX through POST to https://www.example.com/register_email.
If I copy & paste https://www.example.com/register_email in my browser it returns
{"status":"error","message":"Please enter Email"}
but in FileZilla I'm not able to find anything called "register_email", same goes with my hosting's file manager.
Is the site being requested by AJAX owned by you? If not, since you have no control over the site you won't see anything called "register_email" in your server's directory.
When you past it in the browser you get an error is because
browser requests web pages using GET method
no data is being passed
Lastly if the domain (to which the request is being sent) is yours, and you still don't see anything called "registered_email" try searching using filezilla or see if there is an htaccess rule for masking the url

How to get the url serving the current js file

Suppose I have a site at www.somewhere.com that loads a javascript file called Test.js hosted at www.aplace.com. From within Test.js, how can I get the url www.aplace.com?
When I use window.location, I get the url of the site (somewhere.com) instead of the url of Test.js.
The reason I am asking is because I need to make a post request from Test.js to www.aplace.com/dirA/dirB/dirC/Test.js to www.aplace.com/dirD but I can't hardcode the URL.
They should be in <script> in src='{THE_URL}', perhaps try scraping if API is not present.

JavaScript googlemaps read coordinates from file

I want to display some markers using googlemaps. The information (coordinates) are stored in a local *.csv file (wich I want to use a "ressource-file").
How can I read this *.csv file? If I use "jQuery.get('myFile.csv', function (data) {..." it dosn't work.
The error message is: Cross origin requests are only supported for protocol schemes
Do I hava to make a file selection to read the file? Is there no other way?
Thanks
Is it possible that you are trying to load data from a file and not a running server(for example by double-clicking the .html from your file manager)?
If your are on the file:// protocol (which you can see in your url) this will not work. You could try changing to the development directory and runnig python3 -m http.server which will start a small development server. You can than change to http://localhost:8000 and see if it works.

Xml to js code problem

So i'm very new to xml to javascript so i thought I would learn from w3schools, but this site
http://www.w3schools.com/xml/xml_to_html.asp shows an example that I can't mimic locally. I copy/pasted the .js and downloaded the xml but I just get a blank screen!
It's working in there try it yourself but not for me? Do I need it on a server or something?
Yes, that code retrieves the XML data from a web server using AJAX. Since you don't have a server running locally, you can change the URL to point directly to the w3school's version:
xmlhttp.open("GET","http://www.w3schools.com/xml/cd_catalog.xml",false);
Alternatively, play around on their online version ;)
well i guess you have to add the example xml (cd_catalog.xml) to your file system. and you definitively have to access the html file on a server (apache i.e.)
First, ensure that both HTML file (with the Javascript block in it) and XML file are placed in the same directory.
Next, you probably need to place those files under your local web-server and open the HTML like this:
http://[local server host]/ajax.html
instead of opening the file directly from e.g. Windows Explorer:
C:\[path to the file]\ajax.html
For the latter case you'll get an "Access is denied" error.
-- Pavel
Are you running this under a web server or just creating a couple of text files and loading them in your browser?
The "GET" request this relies upon could possibly be failing.
Use Apache or another similar HTTP server and run the example as if it were hosted on the web.

Categories

Resources