We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Javascript img "src" 401 error

Home Forums Programming Javascript img "src" 401 error

Tagged: 

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #14771
    chromebook15
    Customer

    Hello,
    I am appending images to react to text in javascript, and the images are hosted on my site. The script uses the GET and thus a 401 error insues.

    the function in the script uses these $(“img”) and src values modally as per screenshot attachment.
    expected outcome is the last screenshot.
    code on
    http://tpcg.io/U8OUH6
    cpanel where i host the chord images does not allow write access for the images for the public. any idea how/where to host these images, or how to make them available or modify the JS code?
    thanx

    #14775

    Hi,

    if you just put the image URL in the browser address bar, will it load?

    Chief 3D Verger | LinkedIn | Twitter

    #14777
    chromebook15
    Customer
    #14778

    I think this resource is password protected:

    Attachments:
    You must be logged in to view attached files.

    Chief 3D Verger | LinkedIn | Twitter

    #14783
    chromebook15
    Customer

    so,then how can i attach those png files to the site so that they can be manipulated? do i have to upload the images in some other way?
    how do i make the resource publicly available and modifyable?
    within the site i cannot set the permissions to “modify” only read.

    #14788

    you can probably leverage our WordPress plugin for uploading and retrieving images. Check out our Custom Image example.

    Chief 3D Verger | LinkedIn | Twitter

    #15203
    chromebook15
    Customer

    I think i might have bypassed the resource protection by redirecting the “src” files to my site directly as opposed to the previous cpanel link. But the problem persists.

    The script displays chord names and if clicked two modal popover windows appear above and below the css separators <te> </te> showing the chord for guitar and piano as an image.
    On online compilers, it behaves as expected, all divisions triggering images correctly.
    On my site, however, the popovers are being reordered (nested) css-wise and only trigger images at each last evaluation.
    on the right part on the first screenshot, the <te> are all children of li.
    http://tpcg.io/U8OUH6 should now work
    on the left they are messed up and each <te> is parented to the previous <te> and not directly to
    http://chordaedron.com/Tutorial/
    paste on the fields the following for test:
    D# add11,A# M7/5+,G m7,C 7/5+,D# M7/5-,G madd9,A# M79,F add11
    and the output should be as in the first screenshot.
    the strange thing is that on the compiler everything is ok, but the same script copy-pasted on the site works only partially.
    how could i adapt the code to make sure they are nested each to the function that makes the separators and passes them starts at line 346
    function sampleFunction(c, b, a, t) {
    and at line 493 textReplace(arr.join(),”,”,”</te>,<te>”) makes the divisions.
    like in the last screenshot.
    I hope its not too confusing :wacko:

    #15208
    chromebook15
    Customer

    the unfinished sentences:
    ” are messed up and each <te> is parented to the previous <te> and not directly to… < LI >

    and

    how could i adapt the code to make sure they are nested each to LI
    ?
    My bad did not realize these work inside the forum.
    I suspect jquery or something along these lines of code might be at fault:
    Line 275:
    $(function() {

    $(‘te’).on(‘click’, function(){
    var $this = $(this);
    var offset = $this.offset();
    var bb = $(‘img’);
    var aa = bb.parents().filter(‘[name=”pian”]’).children();
    var cc = bb.parents().filter(‘[name=”chit”]’).children();
    $this.attr(‘style’,’background-color:lightgray’);

    if ($this.text().length > 2) {
    var step0 = allcnames.indexOf($(this).text());
    aa.attr({
    src: “http://chordaedron.com/gallery/&#8221; + srcArp[step0] + “.png”,
    etc
    or
    at line 579:

    myList += open li + ‘<te>’ + i0 + ” ” + h0 + ‘</te>’ + “,” + ‘<te>’ +
    sampleFunction(c0,(n1 – n0),c1,n0)
    + ‘</te>’ + “,” + ‘<te>’ + i1 + ” ” + h1 + ‘</te>’ + closed li;
    } else {
    myList += open li + ‘<te>’ + i0 + ” ” + h0 + ‘</te>’ + “,” + ‘<te>’ +
    sampleFunction(c0,((12 + n1) – n0),c1,n0)//
    + ‘</te>’ + “,” + ‘<te>’ + i1 + ” ” + h1 + ‘</te>’ + closed li;

    #15216

    Hi,

    The outputs from both links look identical to me. I guess you already figured it out?

    Chief 3D Verger | LinkedIn | Twitter

    #15230
    chromebook15
    Customer

    I will :) and ill post the solution. its some sort of nesting problem that behaves differently on the cpanel site-builder and the chord images dont show up, I like this challenge. Now I am devouring the book you suggested on javascript, and rewriting the whole mess in a much better way. Any chance you could recommend books on C++ and python? I`m hoping in the near future to make something useful.

    #15239

    glad you made it work! Not sure about programming books on Python and C++. You may check out Amazon’s suggestions though, for instance:

    Chief 3D Verger | LinkedIn | Twitter

    #15487
    chromebook15
    Customer

    some internal site-builder scripts/helper templates like that of cpanel don’t behave as they should in their “custom Html”, I solved the issue by uploading the HTML (js) file on the server and redirecting the link on the published site to that uploaded file on the server. I guess that this is the way someone ought to make a site in the first place, and not use shortcuts. :unsure:

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.