218 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Located in Canada
+4 more
simonbouchard says

Hello,

I downloaded a very old free weather jQuery script. It is working fine, I’ve redesigned it a little bit but the jQuery code is pretty ugly and it miss something very important, cookies support!

It’s simple, we got a form where you enter your city and click “search”. It connect with Google Weather’s API and when the data is found the form fade out and the weather’s data fade in (Date, City, Wheater Icon, Temperature).

The Problem : each time I refresh the page, the data is loss. I need to store the visitor’s city in a cookie. (Edit: Or in the DOM ?)

Someone here can help with that ?

242 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
ATLChris says

Do you want to store it in a cookie for so they can return to the site and have it remembered or just save it in the session to it remembers their Zip during the session?

218 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Located in Canada
+4 more
simonbouchard says
Do you want to store it in a cookie for so they can return to the site and have it remembered or just save it in the session to it remembers their Zip during the session?

Sesssion is good, cookie is better for my situation, but both are welcome.

242 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
ATLChris says

I was going to say you could use PHP to load the zip as a session varible when entered then have the jQuery script grab the session variable from php if it exist. That is what I would do, but I am not a jQuery expert.

218 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Located in Canada
+4 more
simonbouchard says
I was going to say you could use PHP to load the zip as a session varible when entered then have the jQuery script grab the session variable from php if it exist. That is what I would do, but I am not a jQuery expert.

This script use PHP to query Google’s API

header("content-type: text/xml"); $where = $_GET['where']; $xmlData = file_get_contents("http://www.google.com/ig/api?weather=$where"); echo $xmlData;
242 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
ATLChris says

paste the implementation code of the script. How is the zip sent to the script? Post?

2952 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 200+ members
  • Has sold $125,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+10 more
DDStudios says

Get a room guys ! :P

218 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Located in Canada
+4 more
simonbouchard says
paste the implementation code of the script. How is the zip sent to the script? Post?

Send me an email, I’ll send you the script or the URL of my dev environment.

Thank you Chris for your time!

218 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Located in Canada
+4 more
simonbouchard says
Get a room guys ! :P

GNA !!!!

by
by
by
by
by
by