jQuery load to variable

2020-05-31 22:58发布

I need insert result from jQuery load to variable.

Content of elemtent with id test on page ajax.html.

$('#result').load('ajax.html #test');

标签: jquery ajax get
9条回答
再贱就再见
2楼-- · 2020-05-31 23:24
$('#submit').click(function(){ var taval = $("#message").val();
$("#showcomment").load('comments.php', {commentval:taval}) });
查看更多
冷血范
3楼-- · 2020-05-31 23:31

Try using jQuery.get instead.

Eg.

$.get('ajax.html', function (data) {
    data = $(data).find('#test');
    // data contains your html
});
查看更多
爷、活的狠高调
4楼-- · 2020-05-31 23:32

More or less doing the same as above but simpler:

var dt;
    $.get("ajax.html", function (data) {
        dt = data;
        // data contains your html
    });
查看更多
登录 后发表回答