jQuery帖子到Campaign Monitor不起作用

时间:2016-06-19 19:42:31

标签: jquery

我一直在使用此脚本将名称和电子邮件发布到Campaign Monitor。但它不再起作用了?我在'var jform'得到错误。 我得到了ReferenceError:form没有定义: var jform = jQuery(form);

<script>
ajaxValidation = (function(){
	var _ajaxValidation = ajaxValidation;
	return function() {
		var originalResult = _ajaxValidation.apply(this, arguments);
		if(originalResult){
			var iframe_name = "crossdomainpost";
			if(jQuery("#" + iframe_name).length) return true;
			var jform = jQuery(form); // I'm getting error here!
			if(jQuery("input:checkbox[name*='Newsletter']", jform)[0].checked){
				crossDomainPost(iframe_name).done(function(){ jform.submit(); });
			}else{
				return true;
			}
		}
		return false;
	}
})();

function crossDomainPost(iframe_name){
	var iframe = document.createElement("iframe");
	var uniqueString = iframe_name;
	var r = jQuery.Deferred();
	document.body.appendChild(iframe);
	iframe.style.display = "none";
	iframe.id = uniqueString;
	iframe.contentWindow.name = uniqueString;
	iframe.onload = function(){ r.resolve(); }

	var form = document.createElement("form");
	form.target = uniqueString;
	form.action = "http://mydomain.createsend.com/t/r/s/xxxxxxx/";
	form.method = "POST";

	// repeat for each parameter
	var input_name = document.createElement("input");
	input_name.type = "hidden";
	input_name.name = "cm-name";
	input_name.value = jQuery("#RSEProName").val();
	form.appendChild(input_name);
	var input_email = document.createElement("input");
	input_email.type = "hidden";
	input_email.name = "cm-xxxxxxx-xxxxxxx";
	input_email.value = jQuery("#RSEProEmail").val();
	form.appendChild(input_email);

	document.body.appendChild(form);
	form.submit();
	
	return r;
}
</script>

0 个答案:

没有答案