Solved

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

Posted on 2014-09-03
3
325 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
ID: 40302442
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
ID: 40302457
Your amazing lightning fast response seems to work too... awesome, thanks!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40302461
'welcome
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

813 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