-1

I'm capturing user signature writing in base64 string format and allow them to review in fancybox popup for the data they just input. The way i did it is using link () with href set to that data:

<a href="data:image/png;base64,iVBORw0KGgoAAAA...lFTkSuQmCC" class="fancy">click_me</a>

Clicking this link however will trigger "ERR_INVALID_URL", and after drinking much coffee i realize it is due to the target href data has this what seemed to be appended GET param whose value equal to epoch time

...lFTkSuQmCC?_=1412399504179

I wonder how can I get rid of those auto append data. What i already tried is to put $.ajaxSetup({ cache: false }) jsut after document.ready since i thought its relating to some caching feature

Va1iant
  • 203
  • 3
  • 12
  • give me a minute, i'll try to prepare it for you – Va1iant Oct 04 '14 at 05:27
  • ok this is weird, it seemed when i do it in jsfiddle the problem is gone: http://jsfiddle.net/uZCC6/4570/ probably something wrong with my js lib – Va1iant Oct 04 '14 at 05:41
  • your image in the jsfiddle doesn't include the appended parameter `?_=1412399504179` ... if you add it, the image will fail. – JFK Oct 04 '14 at 07:33

2 Answers2

0

The JSFIDDLE you provided doesn't fail because it doesn't include the appended parameter ?_=1412399504179 as in your question.

If you add it, then it fails. See updated JSFIDDLE

If you want to get rid of the trailing parameter you could do

$(".fancy").fancybox({
    beforeLoad: function () {
        var _href = this.href.split("?");
        this.href = _href[0];
    }
});

See forked JSFIDDLE

JFK
  • 40,963
  • 31
  • 133
  • 306
  • you're right @JFK, but my interest was actually to know WHO appended that string in the first place when my html contain only pure base64 data. My bet was at the fancybox library and the motive i'm guessing was to avoid cache by the browser. I'm still looking a way to get rid of that timestamp – Va1iant Oct 04 '14 at 12:33
0

I'm really not sure what cause this, but after many trial and error i figure out my problem gone if i specifically set the fancybox type to 'image'

$(".fancy-img").fancybox({
    type: 'image'
});

as for why the my jsfiddle doesn't seem to have the same problem i'm just clueless. Anyway, thanks for those who answers

Va1iant
  • 203
  • 3
  • 12