Is it possible to call an Ajax from the Marketo script? Like the below given code.
I would need an ajax call as
then to display the results on the page
<script src="//xxxxx.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1"></form>
<script>
MktoForms2.loadForm("//aqq-abc.marketo.com", "xxx-XXX-xxx", id1, function(form) {
form.onSubmit(function() {
var vals = form.vals();
$.ajax({
type: "POST",
url: "http://localhost:3422/wordpress/wp-content/plugins/calM/new_generate.php",
data: {Value1:val[0],Value2: vals[1]},
success: function( data ) {
alert(data);
},
error: function( err ) {alert("Some thing went wrong! Please try again with your values.");}
});
});
});
答案 0 :(得分:0)
这应该在原则上正常工作。取决于你尝试做什么onValidate可能是一个更好的回调事件。
答案 1 :(得分:0)
是的,我可以从Marketo Script调用ajax。需要为此添加jQuery lib。以下是完整的工作片段。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//xxxxx.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1"></form>
<script>
MktoForms2.loadForm("//aqq-abc.marketo.com", "xxx-XXX-xxx", id1, function(form) {
form.onSubmit(function() {
var vals = form.vals();
$.ajax({
type: "POST",
url: "http://localhost:3422/wordpress/wp-content/plugins/calM/new_generate.php",
data: {Value1:vals.Email,Value2: vals.Phone},
success: function( data ) {
alert(data);
},
error: function( err ) {alert("Some thing went wrong! Please try again with your values.");}
});
});
});