-1

I am trying to use an external javascript provided by indeed.com but I can't get it to reload when I change the ind_q variable or the ind_l. It WILL work in IE9 and Safari but will not work in Chrome or Firefox unless I put them in incognito mode. I have tried the suggestion of appending a random # to the end of the ex. script with "?" but no luck. Any clues as to why it would work in 2 browsers but not the others? Guessing it is some kind of cache issue but don't know how to fix it. Also, if I change the ind_n variable (which is the # of results returned, it does change in all browsers)

These are the only variables I can change:

<script type='text/javascript'>
var ind_pub = '55555555555';
var ind_el = 'indJobContent';
var ind_pf = '';
var ind_q = 'job title';
var ind_l = '<?php echo $zip_code; ?>';
var ind_chnl = 'none';
var ind_n = 10;
var ind_d = 'http://www.indeed.com';
var ind_t = 20;
var ind_c = 10;
</script>

This is how I link to the Indeed script:

<script type='text/javascript' src='http://www.indeed.com/ads/jobroll-widget-v2.js'>   </script>
whatdafrak
  • 561
  • 1
  • 6
  • 10
  • [Stack Overflow is not a Mind Reader](http://meta.stackexchange.com/a/128551) – gdoron Jun 03 '12 at 07:27
  • Not a mind reader? Not sure where in my question I asked anyone to read my mind. Only asking if there is a way to force an external javascript file to reload. – whatdafrak Jun 03 '12 at 07:32
  • 1
    You mentioned some `$zip_code` variable. Where is this variable declared? How is it used? Could you show your code? – Darin Dimitrov Jun 03 '12 at 07:34
  • You asume we all know the indeed's job search widget as if it was our best friend. I would simplify your question and show us the code. – huysentruitw Jun 03 '12 at 07:35
  • How do you include the javascript in the first place? Where do you pass this $zipCode to the script? You can just edit the html to remove the current script and add a new one. It will load with the new parameters. – nunespascal Jun 03 '12 at 07:35
  • I'm pretty new at this so maybe I just don't understand the process properly. I only have access to change the variables. Then right after the variables are set, the external script is called and I have no control over that script. If I change the variables and load it in a different browser, the changes take place but if I change again and refresh the page they remain the same – whatdafrak Jun 03 '12 at 07:39
  • @WouterH, I do not even have access to indeed's external javascript file so I cannot include it. I am only given the link to it – whatdafrak Jun 03 '12 at 07:42
  • I've read other posts that all agree if you change the name of the javascript src it will force a refresh, but I don't have that option as the script is not on my server. I'm guessing Indeed doesn't want you to have too many options so users are forced to go to their site so maybe I am limited on purpose – whatdafrak Jun 03 '12 at 07:45
  • It's not clear why you would want to refresh a script. If you are not passing any variables to it, surely it te code won't be any different. Perhaps it works like this: you define some variables, then load the script, which contains a function that runs there and then to insert some ads? – Grezzo Jun 03 '12 at 07:51
  • are they forcing you to set those variables before including there Js file? – huysentruitw Jun 03 '12 at 07:55
  • the way it works is you tell them what job title you want to search and the zip code and they provide you with the code you copy and paste to your page. So I assumed if I could replace the `var ind_l` with my own php echo variable, it would work. And it does if I open the page in a different browser. I understand what you mean. The external script shouldn't have any effect on the result if the variables are defined on the page – whatdafrak Jun 03 '12 at 08:04
  • when I go to their site and change the search terms, the only thing that changes is the `var ind_q` and the `var ind_l` when I look at the code they give me to copy and paste. I just can't get it to change the results when I refresh the page after changing those variables – whatdafrak Jun 03 '12 at 08:07

1 Answers1

2

If you want to force a new download of the script, it's a hacky workaround, but try loading the script dynamically (via a script) and appending something to the end of the URL. e.g. ...js?a=UNIQUE_NUMBER or ...js#UNIQUE_NUMBER. It's a hacky workaround, but could help

Grezzo
  • 2,220
  • 2
  • 22
  • 39
  • yeah i just read somewhere else that the server will ignore anything after the '?' but it's not working. The script still runs just fine but the information doesn't change. – whatdafrak Jun 03 '12 at 08:23
  • here's an interesting twist. When I pull up the page on my ipad, it works just fine. I change the zip code and the results reflect that change every time – whatdafrak Jun 03 '12 at 08:30
  • +1 the `?t=` should work fine here; @whatdafrak it's important to realize that even if the server ignores the parameters after `?`, it's the client that matters. – Ja͢ck Jun 03 '12 at 08:44
  • Yeah it seems like it should work. And it does on ipad. Just not either of my PCs or the 3 browsers on each. If you add `
    ` you can test it with the original code I provided. It just doesn't work.
    – whatdafrak Jun 03 '12 at 08:50
  • another twist. It also works on IE9. And I changed the `var ind_n` which is the amount of results shown and it changed in all browsers. but the job title and zip code variables only change in IE and Safari. It has to be the way they cache but doesn't make sense it would only effect certain variables and not others. It doesn't take much to boggle my mind when it comes to programming but I'm stumped – whatdafrak Jun 03 '12 at 09:02
  • two more possible helpful hints: incognito mode fixes the problem on every browser so definitely a caching issue. Also, my doc is html5 so I don't know if that changes things. Any help would be really appreciated. Thanks – whatdafrak Jun 03 '12 at 09:34
  • What do you mean by you change the zip code and it works on your iPad. Do you have somewhere on your page that you update the variable, then try to reload the script, or do you mean you change the zip code in your javascript source code, then refresh in your browser? Please give us a working example of your code on a site like jsFiddle, then we can have a go at debugging it. At the moment nobody can understand what your problem is because you are either not explaining it well enough, or because from your explanation it should work. If you give us proof that it doesnt work, perhaps we can help. – Grezzo Jun 03 '12 at 12:42
  • and by proof, I mean an example we can view in our browsers (and preferably easily edit like on jsFiddle) – Grezzo Jun 03 '12 at 12:43
  • Excellent idea. I put the code in [jsfiddle](http://jsfiddle.net/crawford252/cU7pP/embedded/result/) but it doesn't work. When I take the code from jfiddle and paste it in an empty html page, works fine in IE so not sure what's going on there. Never used jfiddle so probably operator error. But everything you would need is right there. If you change the zip code via the `ind_l` var it changes in IE but not Chrome. – whatdafrak Jun 03 '12 at 20:06
  • @Grezzo, if you look at the script in jsfiddle, the var ind_l contains the zip code. I want to echo a php variable so it changes dynamically but I'm not even to that point yet. I am just changing that number and saving the page and refreshing the browser and it works in IE and Safari but not Chrome and Firefox. – whatdafrak Jun 03 '12 at 20:20
  • To use jsfiddle, you only put the stuff that goes inside the body in the HTML section, and only the stuff inside the script tags in the script section. It's also possible to add a link to an external script, but that's normally used for external libraries, so is loaded before the script you type in. I'm not sure how to force external script to load after your own script, so I just created a new document on my machine and pasted the code in... – Grezzo Jun 03 '12 at 21:24
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/12080/discussion-between-grezzo-and-whatdafrak) – Grezzo Jun 03 '12 at 21:24
  • Eventually got this to work on other computers on my local network but never on the local machine that the script resided on. Don't know if it had something to do with it being cached on the local machine but hoping when I go live everything will work. Thanks for all the help Grezzo. – whatdafrak Jun 08 '12 at 04:55
  • Glad you got it working. Strange indeed that you still have one machine misbehaving – Grezzo Jun 08 '12 at 06:04