i have problem setting html attribute escaped html json data.
i get:
uncaught syntaxerror: unexpected number on data definition timestamp.
can set integer values in json? how can escape json data put in html data-form-data attribute?
this code:
<input name="file" type="file" id="uploadinput" class="cloudinary-fileupload" data-cloudinary-field="image_upload" data-form-data="" ></input> <script> var data = { "timestamp": 2013-05-06 00:20:17.713, "callback": "https://www.mcbjam.com/scripts/vendor/cloudinary/html/cloudinary_cors.html", "signature": "99c35c139c34e2e42ba9e7af251686015c10e5f3", "api_key": "789575445683743" }; $('#uploadinput').attr('src', encodeuri(data)); </script>
the problem here:
"timestamp": 2013-05-06 00:20:17.713 javascript doesn't have date literals, , although you're not using json there (you're using javascript object initializer, different), fwiw json doesn't have dates @ all. you'd need supply string, or number (for instance, milliseconds since epoch), etc.
fyi, if call encodeuri on javascript object there if initializer weren't invalid, you'd this: "%5bobject%20object%5d" isn't want.
if want take javascript object , turn json string, can use json.stringify that. , if you're putting dom attribute, there's no need uri-encode it. so:
$('#uploadinput').attr('src', json.stringify(data)); but again, json doesn't have dates, you'd have handle before above work.
Comments
Post a Comment