- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
08-21-2018 01:15 AM
//callback function function jsonpcallback(data) { //do stuff with JSON if(data.job_detail_id == utag_data.job_detail_id) { console.log(data.detail_id == utag_data.detail_id); utag_data.TEA_location = data.TEA_location; utag_data.TEA_branche = data.TEA_branche; console.log(utag_data); } } //create HTML script tag var scripthdl = document.createElement('script'); scripthdl.src='//domain/stelle.js?callback=jsonpcallback'; //inject script tag into head document.getElementsByTagName('head')[0].appendChild(scripthdl);
With this little JavaScript, i'm trying to access a JSON file, which by now is looking like this:
jsonpcallback({"detail_id" : "1234567", "TEA_location" : "Kalkutta", "TEA_branche" : "Media" });
On my local machine this works perfect, but if i let Tealium run this, i get an error:
Uncaught ReferenceError: jsonpcallback is not defined at stelle.js?callback=jsonpcallback:1
What am I doing wrong?
Thanks in advance!
Solved! Go to Solution.
08-21-2018 01:23 AM
If you're running that within a function, then it'll be creating the jsonpcallback function locally, which means it won't be accessible to the script that's returned by the JSONP request.
Instead, try replacing that first (non-comment) line with:
window.jsonpcallback = function(data) {
08-21-2018 01:30 AM
Copyright All Rights Reserved © 2008-2023