javascript - Userscript, get data with ajax and get content -


i'm doing userscript website. of articles contains images , when click them opens in page found boring , time wasting decided make userscript instead of opening image in page open in on same page in popup on websites today. i'm using magnific popup this. code far.

var link = ''; var link2 = '';  $("head").append('<link rel="stylesheet" href = "https://49535f300cc62ae84be0bc4341ad834057099639.googledrive.com/host/0b7xsofmydrhqmu9prdjxtetpqwc">');   $(document).ready(function() {      $('section[class="article"]').find("#intellitxt").find('a').each(function(){            link2 =  "http://www.gamergen.com"+ $(this).attr('href');          $.ajax({              url: link2,              success: function (data){link = $(data).find('.big').find('img').attr('src');},              error : function(){alert(link2)}          });          $(this).magnificpopup({               items: {                   src: link               },              type: 'image',              closeoncontentclick: true,              mainclass: 'mfp-img-mobile',              image: {                  verticalfit: true              }          });         });  });    

the popup part working , opens image in popup when click on instead of following link. problem actual link isn't image webpage redirected image is.

this: /image/mort-satoru-iwata-images-captures-splatoon-memorial-condoleance-5-811402-264278 link of image on main page , when click on redirected webpage can find actual url of image : http://global-img.gamergen.com/mort-satoru-iwata-images-captures-splatoon-memorial-condoleance-5_028001c600811402.jpg (everything on same domain , image situated on subdomain. altough don't access ajax want copy link , past on main page in popup)

here's html of that:

<a href="/image/mort-satoru-iwata-images-captures-splatoon-memorial-condoleance-11-811408-264278" title="mort satoru iwata images captures splatoon memorial condoleance (11)" class="zoomlink"><img src="http://global-img.gamergen.com/mort-satoru-iwata-images-captures-splatoon-memorial-condoleance-11_00ce009200811408.jpg" alt="mort satoru iwata images captures splatoon memorial condoleance (11)" width="206" height="146"></a> 

(the image in thumbnail)

so tried using ajax , and url webpage proper url of image located.

just there's problem ajax query, goes error function. i've tried make alert check if url one. , got 2 problems, url same, , second 1 url 1 doesn't enter success function anyway.

i'm kinda new javascript. shouldn't .each every element since .find('a').each ? , what's wrong ajax query?

thank you


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -