?
Solved

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

Posted on 2014-09-03
3
Medium Priority
?
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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)
Suggested Courses

771 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