Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在fileuploader POST响应中获取额外引号_Php_Javascript - Fatal编程技术网

Php 在fileuploader POST响应中获取额外引号

Php 在fileuploader POST响应中获取额外引号,php,javascript,Php,Javascript,我正在使用Valum的文件上传器 下面的index.html上传一个文件,post.php返回一些json。很抱歉没有制作JSFIDLE,但我不知道如何实现ajax响应 使用FF时,responseJSON.icon为 <img src="http://www.tapmeister.com/test/doc.png" width="32" height="32" /> <IMG src='"http://www.tapmeister.com/test/doc.png"' wi

我正在使用Valum的文件上传器

下面的index.html上传一个文件,post.php返回一些json。很抱歉没有制作JSFIDLE,但我不知道如何实现ajax响应

使用FF时,responseJSON.icon为

<img src="http://www.tapmeister.com/test/doc.png" width="32" height="32" />
<IMG src='"http://www.tapmeister.com/test/doc.png"' width='"32"' height='"32"' >

然而,对于IE8,responseJSON.icon是

<img src="http://www.tapmeister.com/test/doc.png" width="32" height="32" />
<IMG src='"http://www.tapmeister.com/test/doc.png"' width='"32"' height='"32"' >

我同意img被资本化,但是,这些额外的报价给我带来了巨大的破坏

这是如何修复的?多谢各位

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>

正文{字体大小:13px;字体系列:arial,无衬线;宽度:700px;边距:100px自动;}
$(函数(){
var uploader=new qq.FileUploader({
元素:document.getElementById('file-uploader-demo1'),
动作:“post.php”,
onComplete:函数(id、文件名、responseJSON){
$('#icons')。追加('
  • '+responseJSON.icon++'+$('').text(responseJSON.icon.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));
      ?>
      

      为什么不在post.php中发送图像的URL,然后在javascript中构建IMG元素呢

      <?php
      echo json_encode(array('icon' => 'http://google.de'));
      ?>
      
      
      
      使用以下方法创建图像:

      $('<img>').attr('src', responseJSON.icon); //...
      

      $(“谢谢W0RLD。如果这是唯一的解决方案,可能最终会这样做。这回答了问题。如果有人知道其他解决方案,请发布。谢谢