Convert a jqplot figure into data url and send as part of html form

可紊 提交于 2019-12-12 00:01:35

问题


I have a dynamic figure which is generated by jqplot. Now I need to pass this plot to another webpage in the PNG format. My solution is

  1. Convert this jqplot as data url in a variable

    var imgData = $('#chart1').jqplotToImageStr({});
    
  2. Send this variable as part of html form to the next page

    $('<tr style="display:none"><td><input type="hidden" name="extract1"></td></tr>')
        .appendTo('.getpdf')
        .find('input')
        .data(imgData);
    

    I also tried to use .val(imgData), which also failed

  3. Print it and check.

    extract1 = form.getvalue('extract1')

    html = html + """'<'img id="imgChart1" src="%s" />"""%(extract2)

However, on the next page, when I tried to print this variable, I got nothing. It seems like it did escape this variable properly. If I assign extract2 with data-url string, it worked. Could anyone give me some suggestions?

Update:

It seems like the problem existed in the step sending image as data-url to the next page. In the new page, if I supply a verified image data-url, it worked.

来源:https://stackoverflow.com/questions/15651477/convert-a-jqplot-figure-into-data-url-and-send-as-part-of-html-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!