Welcome Guest, Not a member yet? Register   Sign In
jQuery ajax and cache problem?
#1

[eluser]ywftdg[/eluser]
We have some jquery ajax script that we setup, to basically just get some db results, and then refresh the value of the span, change out the html. While this works super fast and has no issues on our local dev setups, it never works on the live box. If anything, it works 2/10 times...it seems to be with the cache on the live site, as there are no js errors happening in our logs, etc.

Any ideas?

js:
Code:
function update_name(product_id)
{
$.ajax({
  type: "GET",
  cache: false,
  url: "/user/product_update_name/"+product_id,
  success: function(response) {
   $("#name_"+product_id).html(response);
  }
});
}
#2

[eluser]CroNiX[/eluser]
Try using type POST
#3

[eluser]ywftdg[/eluser]
Tried that, still not working..
#4

[eluser]CroNiX[/eluser]
You say you have cache enabled? CI Cache? If so, your controller won't even get called if the cached item exists and hasn't expired. It will just send the item from cache (with the same headers as it hasn't changed). If the item has expired then your controller will be called and a new cache file will be generated for the next go around.

You might try turning the cache off on the main site and see if that fixes it (just to troubleshoot). You might also try removing the "cache: false" from your js. If the cached item gets returned, I'm thinking your JS is ignoring it because it wants new data.
#5

[eluser]ywftdg[/eluser]
Yeah I am not sure its a cache issue now...as I have tried to disable cache every which way I can, even using chrome and in developer tools turning it off, still no go. Again, works like a charm locally. Its almost acting as if, ok it updates the item in the database, but maybe while the database is still working, its too fast and gets the old value...no idea, but thats the way it seems to be working...almost like the js is running too fast before the db is fully saved...

but that doesn't to ally add up, because we run it on the ajax success...not on complete or anything like that.

even putting an alert in that script, sometimes it runs, sometimes it doesn't...quite strange...




Theme © iAndrew 2016 - Forum software by © MyBB