我正在使用Wordpress和Ninja Form插件。 我想在提交表格时,发布到服务数据。 HTML:
<input type="submit" name="_ninja_forms_field_7" class="ninja-forms-field popup-submit" id="ninja_forms_field_7" value="" rel="7">
JS:
$('#ninja_forms_field_7').click(function () {
var name = $('#ninja_forms_field_6').val();
var surname = $('#ninja_forms_field_6').val();
var emailAddress = $('#ninja_forms_field_8').val();
var eCommerceSiteUrl = $('#ninja_forms_field_9').val();
var post_datas = emailAddress = +emailAddress & name = +name & surname = +surname & eCommerceSiteUrl = +eCommerceSiteUrl;
$.ajax({
type: 'POST',
url: 'myserviceaddress',
data: post_datas,
success: function (answer) {
console.log(answer);
}
});
});
但不行。 我该如何解决?
答案 0 :(得分:1)
var post_datas = "emailAddress="+emailAddress+"&name="+name+"&surname" .....
您错过了网址字符串(数据)的引用。
或尝试更好的解决方案
var post_data = {name: name , email: email},
$.ajax({data: postdata});