How to Pass json array in js mobile

How to Pass json array in js mobile


Hello everyone,

I am trying to pass array in json formated as input parameter in js function


if i hard pasted in code like below it is working fine i am getting expected output

$(function() {


    events: [{"id":0,"title":"available","start":"2018-06-17T10:15:45Z","end":"2018-06-17T10:15:45Z","color":"green","textColor":"","backgroundColor":"","description":""},{"id":0,"title":"available","start":"2018-06-18T10:15:45Z","end":"2018-06-18T11:15:45Z","color":"green","textColor":"","backgroundColor":"","description":""},]



but if passed as input parameter in json format which is same as above format

it throwing error of 400 bad request . I tried to pass as object also but it didn't get output.

I want to pass array of events in function which i am able to get by doing json serialize of list record.

Any idea how to pass and why i am getting ajax request error?


Hi Amin,

To debug this, I think the easiest way is to use a console.log in the JavaScript to see what the input parameter contains, and compare it to what you expect it to be.

Hi Kilian,

Thanks for reply

I used console.log to see and it is in expected format.

The problem is when i passed json array as input parameter it making ajax call to fetch. I want to pass as event array (Events-array).

or i need to pass as json (Json feed)

In this i don't know what will be url and how to pass data

events: {    url: '/myfeed.php',  

          type: 'POST',    

         data: {      custom_param1: 'something',      custom_param2: 'somethingelse'    },}


Hello Amin,

If you need to pass a JSON to a Javascript node, you will need an argument that will be of type "text", right? So in the Javascript it will not be a JSON Object, but instead, but a text.

So, before being able to use it, you have to change the argument back to JSON object using, for example, JSON.parse().



Hi Eduardo,

Thanks for solution.