I am trying to get some xml into a html table. The thing is my xml is created dynamically on the server as a temporary document. How can I call this file if the url can be different? I hope this makes sense. I am new to jQuery, Javascript.
At the time of dynamic generation of the file on the server, also write the path of the file in a static file. Use the client to retrieve the path from the static file and then make the actual request to the dynamically generated file.
hope i understood your question right.
Related
I am new to after effects, I have read article to change text and price through xml file or csv file. But is it possible to read the image file using any URL script.
So my concept is to make one template contains ProductImg, Title, Description and Price, by reading either xml or csv document,
So next time I will replace the xml file. But I have no idea, how to replace product image.
It's possible to do this, but not as simple as changing text data in a Text Layer. You have to use ExtendScript, and I would recommend using the system.callSystem() method to call a command that would download the remote file on a server somewhere. You could use something like wget or curl with the correct parameters to retrieve the file and then import it into After Effects using other ExtendScript methods.
For this type of workflow, I recommend forgoing the use of CSV and XML and just use a cloud-based datastore, like Google Sheets. For this, you would need the Templater software extension by Dataclay to accomplish what you want very easily. Out-of-the-box, Templater handles remote footage assets, you would just need to be sure that the URL to those assets be accessible from the machine that After Effects is running on, and that the URL is a direct link to the asset.
I am going to deploy this page on an FTP
And I need to find out how I can detect the html file currently being viewed using JavaScript.
If I open the html file, it works just fine with this:
var fileName = location.href.substring(location.href.lastIndexOf("/") +1);
But, if I open it via my localhost adress, it has a null value. So I'm guessing I have to use some other method to extract the current html file name. Or is there a better approach to this?
Note: I am not going to use JQuery or anything like that.
EDIT:
I can get the filename if it isn't my index file.. If it's the index file I get nothing using the above code. Most likely since all I have in my adress bar is the localhost adress of the live-server?
The web deals in URLs, not file names.
Sometimes a URL will include something that looks like a file name, and sometimes that even maps on to a real file name on the server's hard disk.
When you type http://example.com/ then it might map that onto a file called index.html. Or maybe on to index.php. Or maybe it won't touch any file but will just use logic built into the web server application to determine what to respond with.
There's no way to know in the general case.
If your specific case, you know that the path / maps onto index.html, so you can write an explicit mapping in your JavaScript code.
I'm using highcharts to create SVG charts. So, the chart is shown in the frontend, with an svgHTML tag.
Now I want to export that chart as an SVG file.
My effort
Since the SVG is generated purely in the frontend, the backend knows nothing about it. And if I want to initialize a download with some content, what I know about it is to make an HTTP response with the content.
So I can simply grab the SVG content as a string, then upload it with an HTTP request, then response the content as it was.
I want it better
I think there is logically no need to transfer by such a way, because the frontend knows everything we want.
I turned for your help: Is it possible to initialize a download in the frontend?
You can generate download links directly using the base64 encoded version of your SVG data.
You just need to add data:application/octet-stream;base64, in front of the base64 encoded data.
Here is a simple fiddle to demonstrate;
http://jsfiddle.net/xkbhf7mo/
EDIT:
You can also specify a filename with download attribute in anchor tag to make things more pretty.
<a download="your_file_name" href='...'>Download</a>
I've been attempting to make this work reading everything, but no luck so far. I generate JSON with php for some records using json_encode and I have it output to a .php page on the server - and example is below:
[{"number":1,"name":"Lizzie","image":"http://scienceblogs.com/scientificactivist/wp-content/blogs.dir/392/files/2012/04/i-dcb85296b3695e8ce6d1ae4d660cea30-Smiley-face.gif"}]
On another server, i'd like to ideally read this JSON output and echo it to the page, but I can seem to read it locally but not remotely. Here is an example how far I got with the code:
$.getJSON("http://www.server.com/json.php",function(ajaxresult){
$("#number").append(ajaxresult.Number);
$("#name").append(ajaxresult.Name);
$("#image").append(ajaxresult.Image);
});
How ever this code will read a local .json file and write the elements out - but not a remote one and consequently not the dynamicly generated remote one.
Any hints to what I've done wrong?
Save the dynamically generated JSON as a temporary local file and read it from there.
I was wondering if it is possible in JS to open a directory, read an image file and display it to Html? I believe JS restricts from being able to open any file in a directory directly, but what I want is:
I have a XML file which will contain the path to a image file in the web server root folder
so my hierarchy is like this
webserver root folder--->|
html
js
css
images
xml
, and I will use XmlHttpRequest and feed the directory tag and file name tag to my JS file which has to display the image to my frame in the Html page.
[My image is also in the same webserver root folder but in a different folder from html]
Any pointers on how to go about it? I guess we can store the image file also in XML as a base64 encoded data, but that would make the data exchange huge, also don't know if this is a ideal method (is it? please suggest)
Please give me some tips for this.
Thanks
Balaji R
JavaScript does not have access to filesystem on server, since it runs on the client side.
But with JavaScript or Ajax you can call some php code on server which will read the image from the file system and then it will pass this image back to the JavaScript.
I have described here how to do this.
If I am following you correctly, example.com/js/somefile.js is trying to access something like example.com/images/image.jpg?
If so then i would either use the absolute URL of the image:
"http://www.example.com/images/image.jpg" or the relative path "../images/image.jpg"
When referencing the images in your code you could actually use a plain text file, one image path per line. Then in your onreadystatechange function:
pictures = var.responseText.split("\n");
now pictures is an array of picture paths.
JavaScript only has access to the information & priviledges that the browser has access to, so unless the image is in a directory that would normally be accessible on the web site, you're not going to have much luck using just JavaScript.
Is there any way that you can make the path in the filesystem available to the web document root folder? Maybe by using an Alias or Symlink?