samedi 20 juin 2015

How to pass JSONObject to JavaScript function during on change event in html

I am populating a JSONObject from backend java and setting it to variable in jsp.

I need to pass the variable to JavaScript function during onchange event.

I am getting syntax error during onchange due to quotes present in the JSONObject.

If I populate as a Map in backend java and I can able to set it to a variable in jsp and pass to JavaScript function successfully.

My question?

  1. Shall we pass the JSONObject in onchange event as mentioned above. If yes what could be the syntax.

I used onchange="getCountries('${countryJSON}')" which is not working.

  1. If we escape the quotes in JSONObject, is it possible to parse the JSONObject in JavaScript function.

  2. Any alternative approach for this issue.

Regards, Selvendran

Aucun commentaire:

Enregistrer un commentaire