Solved

How to load a 3rd party URL from JQuery for tracking

Posted on 2014-09-03
3
310 Views
Last Modified: 2014-09-03
I need to trigger the loading of a 3rd party URL when a JQuery event is triggered. The service I'm using suggests just including a tag like this:
<script src=\"http://exampletrackingservice.com/track?C=82374&source=js\" type=\"text/javascript\"></script>

Open in new window

But that of course gets loaded on the page load rather than when the event is triggered. I tried using a $.get call but got the error:
MLHttpRequest cannot load http://exampletrackingservice.com/track?C=82374&source=js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mysite.com' is therefore not allowed access. 

Open in new window

I don't need to get any data from the URL; I just need to load it. How can I do that from JQuery?

Thanks!
0
Comment
Question by:Terry Woods
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
Your are looking for getScript : http://api.jquery.com/jquery.getscript/

$.getScript("http://exampletrackingservice.com/track?C=82374&source=js");

Open in new window

0
 
LVL 35

Author Closing Comment

by:Terry Woods
Comment Utility
Your amazing lightning fast response seems to work too... awesome, thanks!
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
'welcome
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now