0
이하. .PP 파일을 가져 와서 개인 IP를 확인하고 양식을 표시하는 AJAX 호출이 있어야합니다. 양식을 제출하면 양식을 활성화해야합니다. 두 번째 AJAX 호출 데이터를 제출합니다.제출 기능이 작동하지 않습니까?
module.exports = {
init: function() {
$.ajax({
url: "/microsub.php",
method: 'GET',
success: function (data) {
if (data == 1) {
$('#rdm-below-header').append('<div id=\"modal\" class=\"modalStyle\">' +
'<div>' +
'<button type=\"button\" id=\"close\" class=\"close\" data-dismiss=\"modal\" aria-label=\"close\"><span aria-hidden=\"true\">×</span></button><br>' +
'<div id=\"titleText\" style=\" text-align:center; font-size: 24px; margin-top: 15px;\">Fill in your details for 24hr access to Risk.net</div><br>' +
'<form style="text-align:center; clear:both" id="microsubs_form">' +
'<input type=\"text\" id=\"ms_firstName\" name=\"ms_firstName\" required placeholder=\"First Name\" style=\"float:left;\" >' +
'<input type=\"text\" id=\"ms_lastName\" name=\"ms_lastName\" required style=\"float:left; margin-left:20px;\" placeholder=\"Last Name\">' +
'<input type=\"email\" id=\"ms_email\" name=\"ms_email\" required placeholder=\"Corporate Email address\" pattern=\"^.*(\*barclays|\*barcap.com).*$\" oninvalid=\"this.setCustomValidity(\'Please enter your corporate email\')\" style=\"float:left; margin-top: 10px;\">' +
'<input type=\"password\" id=\"ms_password\" name=\"ms_password\" required style=\"clear:right; margin-top: 10px; margin-left: 20px;\" placeholder=\"Password\" pattern=\".{6,}\">' +
'<input type=\"text\" id=\"microsub_flag\" name=\"microsub_flag\" hidden=\"true\">' +
'<input type=\"submit\" name=\"submit\" style=\"alignment-adjust:central; margin-top:30px; clear:right;\" class=\"msProcess\" id=\"submit\" onclick=\"formSubmit()\"><br>' +
'</form>' +
'<div style=\"text-align:center; clear: both; font-size: 16px; margin-top: 5px; \"><br>' +
'If you already have a subscription, <a href=\"login\">sign in here.</a>' +
'</div>' +
'</div>' +
'</div>');
}
console.log(data);
},
error: function (error) {
console.log(error);
}
});
//Display IP Form
//On Submit form via AJAX
// Bind to the submit event of our form
function formSubmit() {
$("#microsubs_form").submit(function (event) {
var request;
// Abort any pending request
if (request) {
request.abort();
}
// setup some local variables
var $form = $(this);
// Let's select and cache all the fields
var $inputs = $form.find("input, select, button, textarea");
// Serialize the data in the form
var serializedData = $form.serialize();
// Let's disable the inputs for the duration of the Ajax request.
// Note: we disable elements AFTER the form data has been serialized.
// Disabled form elements will not be serialized.
$inputs.prop("disabled", true);
// Fire off the request to /form.php
request = $.ajax({
url: "/ms_form_handler.php",
type: "POST",
data: serializedData,
success: function (data) {
console.log(data);
},
error: function (error) {
console.log(error);
}
});
// Prevent default posting of form
event.preventDefault();
});
}
;
}};
//On Success Hide form, show success message ask to login
//Set cookie to hide the form
//utility.setCookie(name);
dom ID가 아직 존재하지 않을 때'$ ('# micro_subs_form')'이 실행 중일 것입니다. 따라서 실제로 제출하기 위해 제출 호출이 없습니다. –
Marc B는 이벤트가 생성 된 후 '클릭', '제출', 기능 (이벤트) {})에서 .on() 즉 ("msProcess" – Yondaime14