0



I'm trying to concatenate some String variables in Javascript in order to make it contain a file path which has to be calculated to load some flash charts.

If I alert the variable it shows properly 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!

2
  • Please provide us with some code so that we can tell you what is wrong... Commented Feb 17, 2011 at 8:51
  • could it be a random string added to prevent content caching? if so, it's supposed to be ignored by the receiving controller Commented Feb 17, 2011 at 8:55

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I've tested what you said in the last paragraph: I'm able to get the file using both the 'simple' path and also with the question mark and some numbers. But this file is just some data to be loaded into a flash chart which provides that reloadData function to change data origin.
0

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!

1 Comment

If you want to add more information to a question, then please edit the question. Don't answer it with non-answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.