I have an array Like
info['mk'] = 'hi';
info['pk'] = 'hello';
info['wk'] = 'hi';
info['rk'] = 'hello';
And i want to convert in json and send through ajax .
I have an array Like
info['mk'] = 'hi';
info['pk'] = 'hello';
info['wk'] = 'hi';
info['rk'] = 'hello';
And i want to convert in json and send through ajax .
info = {}; //must be set
info['mk'] = 'hi';
info['pk'] = 'hello';
info['wk'] = 'hi';
info['rk'] = 'hello';
then JSON.stringify(info);
Try this:
info={}
info['mk'] = 'hi';
info['pk'] = 'hello';
info['wk'] = 'hi';
info['rk'] = 'hello';
$.ajax({
type: "POST",
dataType: "json",
data: JSON.stringify({info:info}),
url: "",
success: function(msg){
}
});
You should try something like this:
$.ajax({
type: "post",
url: "target",
data: info
});
You could try like this
var info = [];
var tmpObj = {};
info['mk'] = 'hi';
info['pk'] = 'hello';
info['wk'] = 'hi';
info['rk'] = 'hello';
tmpObj.arr = info;
$.ajax({
type: "post",
url: "target",
datatype:"json",
data: tmpObj
});