Solved

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

Posted on 2014-09-03
3
347 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 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

729 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