Skip to content Skip to sidebar Skip to footer

Pass Javascript Array To Cherrypy With Ajax

I'm trying to send an array to cherrypy but it turns out empty. This is my js file. I've checked and the array gets filled as it should. $(function () { $('#mark-read').on('click',

Solution 1:

You should call $.ajax simply with data: {alerts: alert_ids} instead of data: JSON.stringify({alerts: alert_ids}).

Also, remove the contentType : "application/json", line. CherryPy exposed methods expect form-urlencoded format, not json.

If you set traditional: true, you must not add the braces after the alerts parameter in CherryPy, otherwise you must add them.

Post a Comment for "Pass Javascript Array To Cherrypy With Ajax"