开发者

How to grab a href value in a simplemodal call and pass the query string along?

开发者 https://www.devze.com 2023-01-29 23:50 出处:网络
I\'m trying to get a php page to load in a simplemodal window, and to pass a query string along, something like

I'm trying to get a php page to load in a simplemodal window, and to pass a query string along, something like

<a href="my_script.php?var1=value1&var2=value2" cla开发者_C百科ss="simple_modal">

What JS code would I need to load the href value of the clicked link into a simplemodal window (via an iframe or any other mean) ?


Something like this should work:

$('a.simple_modal').click(
    function (e) {
        e.preventDefault();
        $.get(this.href, function(data) {
            var resp = $('<div></div>').append(data); // wrap response
            $(resp).modal();
        });
    }
);

UPDATE: You may need to wrap the response in a div for proper handling in jQuery (see above)


you can use the attr property to get the href value

    $("a").attr("href")

$('.simple_modal').click(function() {
   var hrefval= $(this).attr("href");

});
0

精彩评论

暂无评论...
验证码 换一张
取 消