Home › Forums › Programming › Javascript img "src" 401 error
Tagged: permissions
- This topic has 11 replies, 2 voices, and was last updated 5 years, 5 months ago by chromebook15.
-
AuthorPosts
-
2019-05-15 at 7:38 am #14771chromebook15Customer
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?
thanx2019-05-15 at 8:58 am #14775Yuri KovelenovStaff2019-05-15 at 9:22 am #14777chromebook15Customer2019-05-15 at 9:24 am #14778Yuri KovelenovStaff2019-05-15 at 9:42 am #14783chromebook15Customerso,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.2019-05-15 at 9:51 am #14788Yuri KovelenovStaff2019-05-31 at 3:50 pm #15203chromebook15CustomerI 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 confusing2019-06-01 at 10:01 am #15208chromebook15Customerthe 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;2019-06-02 at 10:57 am #15216Yuri KovelenovStaff2019-06-02 at 11:27 am #15230chromebook15CustomerI 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.
2019-06-03 at 6:55 am #15239Yuri KovelenovStaff2019-06-08 at 3:46 pm #15487chromebook15Customersome 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.
-
AuthorPosts
- You must be logged in to reply to this topic.