I’m not a experienced developer yet, so please forgive me if I sound too noobish or not clear enough. I’ll try to be as clear as I can. If some info is missing for your insights, please let me know and I’ll follow up to that asap.
So,
The company I work has two kinds of pages running with different jQuery versions (1.2 and 1.4). In addition we run the site through some different domains, eg: company.com, support.company.com, contact.company.com.
company.com runs in jQuery 1.4 (we can access jQuery only with “$”) and the other on 1.2 (where jQuery is “$j” or “jQuery”).
We have an API which retrieves a lot of information from the products like its price, image, descripton, etc. This API we can call on the pages with the 1.4 version of jQuery. The other domains we can’t get any information via this API.
We can only deal here with javascript and jquery codes to make it work. We don’t have access to back end.
So my question is: what is the approach I should have to make the API works from both kind of enviroments on the pages? Can I overwrite the oldest version? Is this an cross-domain issue? What line of thought I’m looking here to solve this problem?
I really hope I’m clear. If not, please let me know and I’ll try to clarify it. 🙂
Thanks in advance!
As far as i know, jQuery overwrites itself when loaded twice, since they both use the same
$variable. there is a way to make one go around and get assigned to another namespace while the other stays as is.I think jQuery does have some backwards compatibility with the older API. Just try to check your site’s APIs to verify if those methods still exist. Some methods have been deprecated lately. Otherwise, you’ll just have to rebuild your API using the latest jQuery. It shouln’t be that hard though, nothing much has changed for the basic methods. You might even get improved performance using the latest methods (those that did not yet exist prior to 1.4)
And tell senior management that they should think of a better strategy than creating two APIs. The effects of not planning APIs to be maintainable and scalable are starting to appear.