If I alert the variable it shows properl开发者_如何学JAVAy but when i invoke the method to load the chart I get an error cause the path it receives isn't the one I see on the alert and thus the one it should be. It's the same string but with some numbers added at the end preceded by an interrogation mark, like '?1297931086408' for example.
Therefore the path is the right path plus this substring which is 'unloadable'.
Thanks in advance for your help!
The problem is not on your javascript. It's on your server.
For a server, this path:
/path/to/my_file.csv
Should be equivalent to this other path:
/path/to/my_file.csv?1425432456
Inside a url, the part to the left of the question mark references the resource being requested. The part to the right are parameters.
That "random number" at the end is a parameter that prevents caching. If it wasn't there, most browsers will say "hey, I already know what is on /path/to/my_file.csv, I don't need to get it again" and will use a cached version of the data. Chances are that flashmovie.reloadData is adding that parameter itself.
Make sure that the file get downloaded if you type its address directly into the browser url bar. Then, try adding a question mark and some random numbers. If that doesn't work, then your server is being overzealous on its url validation.
The code is pretty simple:
function setDataModified(businessUnit){
var path = "https://....";//Complete path
var csvPath;
var xmlPath = path + "Monthly%20Charts/" + businessUnit + "/";
var csvPath = "";
csvPath = path + "Monthly%20Charts/";
//Take data from the form
var selectedMonth = document.getElementById("monthForm").value;
var selectedYear = document.getElementById("yearForm").value;
//Generate csv's path
csvpath += selectedYear + "/" + selectedMonth + "/Monthly_" + businessUnit + "standardChart__" + selectedMonth + "_" + selectedYear + ".csv";
//setData call
var flashMovie = document.getElementById("amcolumn1");
alert(csvPath);
flashMovie.reloadData(csvPath);//csvPath contains the path and also some numbers like '?129..'
}
When I try to load the new chart i get and error message pointing out the error and the wrong path, i.e. with the added numbers at the end. Thanks!
精彩评论