Javascript img "src" 401 error

Home Forums Programming Javascript img "src" 401 error

Tagged: 

This topic contains 11 replies, has 2 voices, and was last updated by Avatar chromebook15 1 month, 1 week ago.

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

    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

    Attachments:
    You must be logged in to view attached files.
    #14775
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Hi,

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

    Founder & CEO at Soft8Soft
    LinkedIn | FB | Twitter | VK | 新浪微博

    #14777
    Avatar
    chromebook15
    Licensee
    #14778
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    I think this resource is password protected:

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

    Founder & CEO at Soft8Soft
    LinkedIn | FB | Twitter | VK | 新浪微博

    #14783
    Avatar
    chromebook15
    Licensee

    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
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

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

    Founder & CEO at Soft8Soft
    LinkedIn | FB | Twitter | VK | 新浪微博

    #15203
    Avatar
    chromebook15
    Licensee

    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:

    • This reply was modified 1 month, 2 weeks ago by Avatar wpadm. Reason: fixed formatting
    • This reply was modified 1 month, 2 weeks ago by Avatar wpadm.
    Attachments:
    You must be logged in to view attached files.
    #15208
    Avatar
    chromebook15
    Licensee

    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/” + 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;

    • This reply was modified 1 month, 2 weeks ago by Avatar chromebook15.
    #15216
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    Hi,

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

    Founder & CEO at Soft8Soft
    LinkedIn | FB | Twitter | VK | 新浪微博

    #15230
    Avatar
    chromebook15
    Licensee

    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.

    • This reply was modified 1 month, 2 weeks ago by Avatar chromebook15.
    #15239
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

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

    Founder & CEO at Soft8Soft
    LinkedIn | FB | Twitter | VK | 新浪微博

    #15487
    Avatar
    chromebook15
    Licensee

    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.