5
मैं एसीमेलिंग जूमला का उपयोग करना चाहता हूं! घटक example.com/mailer पर स्थापित example.comAJAX द्वारा सबमिट किए गए फ़ॉर्म से प्रतिक्रिया कैसे प्राप्त करें?
पर गैर जूमला साइट से सदस्यता को प्रबंधित करने उस मामले में मैं सरल स्क्रिप्ट
$(function() {
$('form').on('submit', function (e) {
e.preventDefault();
$.ajax({
type: 'post',
url: 'https://example.com/mailer/index.php?option=com_acymailing&ctrl=sub',
data: $('form').serialize(),
success: function() {
swal('Great success!');
}
});
});
});
और फार्म का
<form class="form-inline" action="https://example.com/mailer/index.php?option=com_acymailing&ctrl=sub" method="post">
<div class="form-group">
<label class="sr-only" for="user_name">Email address</label>
<input id="user_name" type="text" name="user[name]" value="" class="form-control" placeholder="Email">
</div>
<div class="form-group">
<label class="sr-only" for="user_email">Password</label>
<input id="user_email" type="text" name="user[email]" value="" class="form-control" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Sign Up!</button>
<input type="hidden" name="user[html]" value="1" />
<input type="hidden" name="acyformname" value="formAcymailing1" />
<input type="hidden" name="ctrl" value="sub"/>
<input type="hidden" name="task" value="optin"/>
<input type="hidden" name="redirect" value="https://example.com"/>
<input type="hidden" name="option" value="com_acymailing"/>
<input type="hidden" name="visiblelists" value=""/>
<input type="hidden" name="hiddenlists" value="1"/>
</form>
सब कुछ सफलता के अलावा ठीक काम करता है, त्रुटि राज्य ...
जूमला ए cymailing ajax प्रतिक्रियाओं
संभाल करने sub.php फ़ाइल हैif($config->get('subscription_message',1) || $ajax){
if($allowSubscriptionModifications){
if($statusAdd == 2){
if($userClass->confirmationSentSuccess){
$msg = 'CONFIRMATION_SENT';
$code = 2;
$msgtype = 'success';
}else{
$msg = $userClass->confirmationSentError;
$code = 7;
$msgtype = 'error';
}
}else{
if($insertMessage){
$msg = 'SUBSCRIPTION_OK';
$code = 3;
$msgtype = 'success';
}elseif($updateMessage){
$msg = 'SUBSCRIPTION_UPDATED_OK';
$code = 4;
$msgtype = 'success';
}else{
$msg = 'ALREADY_SUBSCRIBED';
$code = 5;
$msgtype = 'success';
}
}
}else{
if($modifySubscriptionSuccess){
$msg = 'IDENTIFICATION_SENT';
$code = 6;
$msgtype = 'warning';
}else{
$msg = $modifySubscriptionError;
$code = 8;
$msgtype = 'error';
}
}
if($msg == strtoupper($msg)){
$source = acymailing_getVar('cmd', 'acy_source');
if(strpos($source, 'module_') !== false){
$moduleId = '_'.strtoupper($source);
if(acymailing_translation($msg.$moduleId) != $msg.$moduleId) $msg = $msg.$moduleId;
}
$msg = acymailing_translation($msg);
}
$replace = array();
$replace['{list:name}'] = '';
foreach($myuser as $oneProp => $oneVal){
$replace['{user:'.$oneProp.'}'] = $oneVal;
}
$msg = str_replace(array_keys($replace),$replace,$msg);
if($config->get('redirect_tags', 0) == 1) $redirectUrl = str_replace(array_keys($replace),$replace,$redirectUrl);
if($ajax){
$msg = str_replace(array("\n","\r",'"','\\'),array(' ',' ',"'",'\\\\'),$msg);
echo '{"message":"'.$msg.'","type":"'.($msgtype == 'warning' ? 'success' : $msgtype).'","code":"'.$code.'"}';
}elseif(empty($redirectUrl)){
acymailing_enqueueMessage($msg,$msgtype == 'success' ? 'info' : $msgtype);
}else{
if(strlen($msg)>0){
if($msgtype == 'success') acymailing_enqueueMessage($msg);
elseif($msgtype == 'warning') acymailing_enqueueMessage($msg,'notice');
else acymailing_enqueueMessage($msg,'error');
}
}
}
और JSON द्वारा index.php? विकल्प एक ही फार्म के लिए जूमला पक्ष पंजीकरण पर की तरह लग रहा = & ctrl com_acymailing = उप
message Subscribe confirmed
type success
code 3
{"message":"Subscribe confirmed","type":"success","code":"3"}
सवाल है: बाहरी सबमिशन फॉर्म (पर example.com पृष्ठ पर उस सबमिशन स्थितियों को सफलता, त्रुटि, पहले ही सबमिट की गई आदि प्राप्त करने के लिए कैसे प्राप्त करें)?
अपने AJAX कॉल में 'डेटा टाइप' को 'json'' पर सेट करें। सफलता में एक चर को 'सफलता (डेटा)' जैसे तर्क के रूप में रखें और इसे 'data.message' जैसे उस दायरे में उपयोग करें। सफलता के लिए अन्य तर्कों को पारित करने के लिए jquery दस्तावेज़ पढ़ें, त्रुटि ... – frz3993
धन्यवाद लेकिन कोई सफलता नहीं :( 7 घंटों के भीतर मैं इस धागे के लिए बकाया सेट करूंगा – PipBoy2000
यह बेहतर होने में मदद करेगा कि क्या हो रहा है: क्या आप खोल सकते हैं क्रोम देव टूल्स, नेटवर्क मॉनिटर और अनुरोध स्थिति की जांच करें? क्या यह कंसोल टैब पर 200 है? क्या आपको कोई चेतावनी दिखाई देती है? –