drfals1307 2013-05-24 19:59
浏览 29

在Jquery AJAX中显示PHP数据

I have a php page where I display few images with radio buttons. On start two images are pre selected and I merge those and show the combinations. But user can choose a different image and click on MergeImages button, which should display the combination of two images selected.

I am doing this in one php file, where I pass the selected contents via POST to the same file through AJAX.

$.ajax({
          url: 'CreateImage.php',
          type: 'POST',
          data: {imagename : newImageName},
          success: function(data) {
          },
          error: function(jqXHR, textStatus, errorThrown) {
            console.log(textStatus, errorThrown);
          }
    });

I am getting a success and now I would like to display the data so that I can see the newly created images. How do I do this?

  • 写回答

3条回答 默认 最新

  • dongli7236 2013-05-24 20:04
    关注

    You'll want to send with the ajax call the "dataType: 'image'," so the ajax call knows what to do with the returning data -- other options that I've used are dataType:'json' or 'text' or 'html', etc. http://docs.jquery.com/Specifying_the_Data_Type_for_AJAX_Requests

    actually it won't take anything but a string, so send back the image src to display. (I was thinking you wanted to return the actual image itself).

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能