ajax – Failed to load resource: the server responded with a status of 500 (Internal Server Error) through wp_admin_ajax.php
Question
this is the server error log generated
[Sat Oct 23 19:39:50.880944 2021] [:error] [pid 14841:tid 47226270963456] [client 61.245.170.73:48465] [client 61.245.170.73] ModSecurity: Warning. Match of "rx \\/wc-api\\/KCO_WC_Validation\\/" against "REQUEST_URI" required. [file "/etc/apache2/conf.d/modsec_vendor_configs/imunify360-full-apache/002_i360_1_infectors.conf"] [line "51"] [id "77140164"] [msg "IM360 WAF: Infectors: PHP Injection Low value||T:APACHE||MVN:REQUEST_URI||MV:/wp-admin/admin-ajax.php||SC:/home2/mrcstude/ictknowledgehub.com/wp-admin/admin-ajax.php"] [severity "DEBUG"] [tag "service_o"] [tag "service_i360"] [hostname "www.ictknowledgehub.com"] [uri "/wp-admin/admin-ajax.php"] [unique_id "YXRlBmtzrVqCoVAH4CfJFgAATws"], referer: https://www.ictknowledgehub.com/wp-admin/plugin-editor.php?file=MLM%2Fincludes%2Fadmin%2Fjs%2Fblm.admin.ajax.js&plugin=MLM%2Fbinary-level-marketting.php
this is the javascript file
jQuery( document ).ready( function( $ ) {
/**
* The file is enqueued from inc/admin/class-admin.php.
*/
$( ‘#nds_add_user_meta_ajax_form’ ).submit( function( event ) {
event.preventDefault(); // Prevent the default form submit.
// serialize the form data
var ajax_form_data = $("#nds_add_user_meta_ajax_form").serialize();
//add our own ajax check as X-Requested-With is not always reliable
ajax_form_data = ajax_form_data+'&ajaxrequest=true&submit=Submit+Form';
console.log(ajax_form_data);
$.ajax({
url: params.ajaxurl, // domain/wp-admin/admin-ajax.php
type: 'post',
data: ajax_form_data
})
.done( function( response ) { // response from the PHP action
$(" #nds_form_feedback ").html( "<h2>The request was successful </h2><br>" + response );
})
// something went wrong
.fail( function() {
$(" #nds_form_feedback ").html( "<h2>Something went wrong.</h2><br>" );
})
// after all this time?
.always( function() {
event.target.reset();
});
});
});
this is the response function
function save_member_ajax () {
//ajax processing
if( isset( $_POST['ajaxrequest'] ) && $_POST['ajaxrequest'] === 'true' ) {
// server response
echo '<pre>';
print_r( $_POST );
echo '</pre>';
$mb = new Member();
$mb->setMemid($_POST['memid']);
$mb->setParent_ID($_POST["parentid"]);
$mb->setUsername($_POST["username"]);
$mb->setPassword($_POST["password"]);
$mb->setFirstname($_POST["firstname"]);
$mb->setLastname($_POST["lastname"]);
$mb->setOptgender($_POST["gender"]);
$mb->setBirthdate($_POST["birthdate"]);
$mb->setAddress($_POST["address"]);
$mb->setCity($_POST["city"]);
$mb->setState($_POST["state"]);
$mb->setCountry($_POST["country"]);
$mb->setPincode($_POST["pincode"]);
$mb->setMobile($_POST["mobile"]);
$mb->setEmail($_POST["email"]);
$mb->setImage($_POST["image"]);
$mb->setACC_FLAG($_POST["ACC_FLAG"]);
$mb->Insert();
wp_die();
}
this is the action hook
$this->loader->add_action( 'wp_ajax_nds_form_response', $plugin_admin, 'save_member_ajax');
hope your valuable suggestions !!!
0
10 months
2021-10-23T21:59:54-05:00
2021-10-23T21:59:54-05:00 0 Answers
0 views
0
Leave an answer