My problem is similar to that of the question in this link. I need to return multiple slices or a struct from golang to the ajax success block. I tried to marshal my slice into JSON but it is received in ajax as a string. I need to receive it as an array. Is it possible to send multiple arrays or a struct like this?
My code:
b, _ := json.Marshal(aSlice) // json Marshal
c, _ := json.Marshal(bSlice)
this.Ctx.ResponseWriter.Write(b) // Beego responsewriter
this.Ctx.ResponseWriter.Write(c)
My ajax:
$.ajax({
url: '/delete_process',
type: 'post',
dataType: 'html',
data : "&processName=" + processName,
success : function(data) {
alert(data);
alert(data.length)
}
});
Thanks in advance.