Look at my code, I am trying to combine all value from the jquery.each to a string like this ok,good, and then passed to ajax value. Appreciate. or array('ok','good') acceptable also
var global = {
"44":["onset","frequency"],
"45":["onset"]
};
var $val = global[44];
jQuery.each( $val, function( key ,value) {
var value = $('#'+value).val();
});
var $combine = ;//not sure how to combine all value like this (ok,good), or array(ok,good) acceptable also
var data= {
action: 'check_first',
AjaxFrontNonce : ajax_csky.AjaxFrontNonce,
combine : $combine
}
<input type="hidden" id="onset" value="ok">
<input type="hidden" id="frequency" value="good">
Try this working snippet
var global = {
"44": ["onset", "frequency"],
"45": ["onset"]
};
var $val = global[44];
var arr = [];
$.each($val, function(key, val) {
var value = $('#' + val).val();
arr.push(value);
});
var $combine = arr; //not sure how to combine all value like this (ok,good), or array(ok,good) acceptable also
console.log($combine);
var data = {
action: 'check_first',
//AjaxFrontNonce : ajax_csky.AjaxFrontNonce, not defiend
combine: $combine
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="hidden" id="onset" value="ok">
<input type="hidden" id="frequency" value="good">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With