+ Start a Discussion
Genesis YauGenesis Yau 

Is it possible to use a static resource containing an array of strings in a Visualforce page?

I want to write a JQuery function that requires a list of strings like:
[
"string1",
"string2",
"string3",
"string4"
]
Since the list is quite long, I was wondering if I could just add a static resource on Salesforce containing the array and then retrieve it from my JQuery code.

I tried creating a static resource containing the exact same content above and tried to get its content by writing:
var testList = "{!URLFOR($Resource.testList)}";
console.log(testList);
However, the browser console only shows the URL
/test/resource/*****************/testCList



 
Best Answer chosen by Genesis Yau
Genesis YauGenesis Yau
I used Ajax and the Resource URL
 
$.ajax({
        	async: false,
        	url: "{!$Resource.testList}",
        	dataType: 'json',
        	success: function(response){
         	  testList = response;
        	}
});

 

All Answers

Genesis YauGenesis Yau
Edit:  the resource URL is 
/test/resource/*****************/testList
Genesis YauGenesis Yau
I used Ajax and the Resource URL
 
$.ajax({
        	async: false,
        	url: "{!$Resource.testList}",
        	dataType: 'json',
        	success: function(response){
         	  testList = response;
        	}
});

 
This was selected as the best answer