AnsweredAssumed Answered

Munchkin + jQuery + Prototype aren't playing nice together

Question asked by 0fa129cb539a5097d3adbb478bc536caa9f18a4e on Aug 13, 2013
Latest reply on Aug 13, 2013 by 2039
Hey JS Gurus,

I am trying to implement the munchkin associateLead function on a third-party SaaS's login page (Blackboard's LMS if you cared to know).  I am only allowed to put any JS code at the bottom of the page where normally just the Google Analytics JS would go.

So I have a code block that will load jQuery and then dynamically load munchkin and once all of that is done, I clear the _mkto_trk and fire the init.  All this is working well.  

The problem is when I want to use the Munchkin associateLead bound to the login page's submit event.  So all that works EXECPT the mktoMunchkinFunction('associateLead', json , hash); function that throws an "Caught Exception TypeError undefined"  inside the Prototype JS library as the top of the stacktrace which looks a lot like a Prototype/Munchkin conflict

Here is the data
{ Email: '' }

and the exception  Cannot call method 'toString' of undefined somewhere deep inside the Prototype library, 


After having a look in the community I found this article which seems to be the same issue

     JavaScript Errors - Munchkin Conflict

The article suggests moving Munchkin to the head but in this case it is a third-party product and my admin is not particularly comfortable, nor does he have access, in changing the vendor's login page. 

I also followed this one

     associateLead is not creating leads. How can I debug it?

So I tried Erik Rehn's version of the munchkin beta that removed the dependency on jQuery.  That might work but now I am running into a Marketo server restriction on the Same Origin policy.  See the following article:

Munchkin support for jquery > 1.8.3

And now I get the error below on munchkin execute, which I think this means that Marketo's receiving server does not have the header set for Access-Control-Allow-Origin: *

XMLHttpRequest cannot load… Origin is not allowed by Access-Control-Allow-Origin

The munchkin beta might be causing this and it could be a red herring, but I don't think so as the browser is trying to make the call but is blocked.  

It could be that I would have receive this error using the standard munchkin anyways and the Prototype error is masking this one but have I no way to tell.

BTW: is just my test server on my laptop but I am on the corporate network

So I am a bit stuck. Anyone have any insights?