My Jquery code is
jQuery(".loginbtn").click(function(e) {
var value = JSON.stringify(jQuery(jQuery('#form-login input[class!="noAjax"]'), jQuery('#form-login')).serialize());
alert(value); // here I am able to see "username=itsvalue&password&itsvalue...."
jQuery.ajax ({
type : "POST",
url : "index.php?option=com_ajax&module=socialauth&method=loginUser&format=json",
data : value,
contentType: "application/json",
success : function(response) {
jQuery("#login-msg").html(response['data']);
},
error : function(jqXHR, error, errorThrown) {
if(jqXHR.status){
jQuery("#login-msg").html(jqXHR.responseText + jqXHR.status);
}else{
alert("Something went wrong");
}
}
});
});
Here is my PHP helper code:
public static function loginUserAjax() {
// Required objects
$input = JFactory::getApplication()->input;
var_dump((new JInput($input->get('data', '', 'array')))->getString('username') );
}
here I am not getting any POSTed data. I have tried many things. I don't know why.