I am using Valum’s fileuploader http://valums.com/ajax-upload/
The below index.html uploads a file, and post.php returns some json. Sorry for not making a jsfiddle, but don’t know how to implement the ajax response.
With FF, responseJSON.icon is
<img src="http://www.tapmeister.com/test/doc.png" width="32" height="32" />
With IE8, however, responseJSON.icon is
<IMG src='"http://www.tapmeister.com/test/doc.png"' width='"32"' height='"32"' >
I am okay with img being capitalized, however, those extra quotes are causing me havoc.
How is this fixed? Thank you
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="fileuploader.css" rel="stylesheet" type="text/css">
<style>body {font-size:13px; font-family:arial, sans-serif; width:700px; margin:100px auto;}</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="fileuploader.js" type="text/javascript"></script>
<script>
$(function(){
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: 'post.php',
onComplete: function(id, fileName, responseJSON){
$('#icons').append('<li>'+responseJSON.icon+' '+$('<span/>').text(responseJSON.icon).html()+'</li>');
},
debug: true
});
});
</script>
</head>
<body>
<div id="file-uploader-demo1"></div>
<ul id="icons"></ul>
</body>
</html>
post.php
<?php
$icon='<img src="http://www.tapmeister.com/test/doc.png" width="32" height="32" />';
$data=array('icon'=>$icon, 'other'=>'other data');
echo(json_encode($data));
?>
Why don’t you just send the URL of the image in your post.php and then build the IMG-Element in your javascript?
Create Image Using: