Question

I'm trying to interface with Adobe Test & Target because I want to load JSON rather than markup through my mbox. I want to load some mbox content into javascript and manually add it to the DOM. I have searched all over for full documentation of the mbox.js but I can't find anything other than the very basics. It describes how to use mboxDefine() and mboxUpdate to target a specific dom element. Is there a function that just returns the content? ```

Was it helpful?

Solution

T&T does not offer a function to assign the response to a javascript variable. Basically the way it works is mbox.js builds a url to their server and then then outputs a script include tag. This is done to get around the same origin policy limitations (cross-site scripting).

In order to handle whatever is in the html offer, they put it in their own javascript variable on their server and then output it as that as the response. However, they also have the response output the code that updates the target element. So there's nothing you can do to actually stop them from updating the target element with the html offer contents. They simply don't expose that.

However, you don't have to put html in an html offer. You can put json (javascript) in an html offer. Just do like

html offer 'myJsonMbox' (in interface)

<script type='text/javascript'>
var myJsonString = "[json string]";
</script>

Then on your page (inside your body tag, but before your code that wants to use it) you'd have the regular mbox code:

<div class='mboxDefault'></div>
<script type='test/javascript'>
mboxCreate('myJsonMbox');
</script>

And then somewhere after that, where you're wanting to do something with it, that myJsonString is there for you to reference. Or, you can do it with the mboxDefine and mboxUpdate sometime after page load, if you prefer.

Is there some particular reason why you don't think this will work for you?

OTHER TIPS

You can:

a- Insert JS code you are going to use to manually manipulate the DOM

b- Insert CSS code you can use to alter the original HTMl or the newly added HTML.

c- Insert a call to a 3rd party script that will load content from a 3rd party server if needed, or the same server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top