Hi, I have simple 1 html page. I have added munchkin code in that page. I am trying to create lead in Marketo from html page but its not working. The SHA1 key i have generated using http://www.sha1-online.com/
key = xxx
value = "ba4de953201fd7fb30def96cbcd182731584a356"
I have hosted this page on tomcat. I am facing error: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://876-swj-450.mktoresp.com/webevents/visitWebPage?_mchNc=1429178936958&_mchCn=&_mchId=876-SWJ-4.... (Reason: CORS request failed)."
I have already enabled cross domain in tomcat web file.
Below is the code for page
<html>
<head>
<title>Page 1</title>
<script type="text/javascript">
(function() {
var didInit = false;
function initMunchkin() {
if(didInit === false) {
didInit = true;
Munchkin.init('xxxxxx');
console.log("init");
}
}
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://munchkin.marketo.net/munchkin.js';
s.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
initMunchkin();
}
};
s.onload = initMunchkin;
document.getElementsByTagName('head')[0].appendChild(s);
})();
</script>
<script type="text/javascript">
function MarketoUpdate() {
alert("inside fun");
Munchkin.munchkinFunction('clickLink', {
href: '/MyFlashMovie/Story1'}
);
alert("after fun 1");
Munchkin.munchkinFunction('associateLead',{
Email: 'megha_64@yahoo.com',
FirstName: 'kohli',
LastName: 'megha' },
'ba4de953201fd7fb30def96cbcd182731584a356');
alert("ret fun");
}
</script>
</head>
<body>
<form name="form1" onsubmit="MarketoUpdate()">
<label for="fname">Fisrt Name</label>
<input type="text" name="fname"/>
<label for="lname">Last Name</label>
<input type="text" name="lname"/>
<br/>
<label for="email">Email</label>
<input type="email" name="email"/>
<br/>
<label for="company">Company</label>
<input type="text" name="company"/>
<br/>
<input type="submit" value="Submit"/>
</form>
<a href="page2.html">Link to page 2</a>
<a href="page3.html">Link to page 3</a>
</body>
</html>
Please suggest what's wrong in this code?
Solved! Go to Solution.