javascript - get iframe src in a page loaded via jquery $.get? -
i'm loading page using $.get, page load has iframe. know iframe id, reason cant src value...
assuming code
function loadpage(postid) { $.get("/post/" + postid, function(data) { var p = $(data).find("iframe").attr('src'); console.log(p) }) } i undefined result...
but console of data object complete valus need...i'm not sure if problem of selecting in right way
the following should work:
$.get('/somescript', function(result) { var framesource = $('iframe', result).attr('src'); alert(framesource); }); here's live demo. make sure not violating same origin policy. that's why it's better use relative urls when performing ajax requests (/somescript).
Comments
Post a Comment