jquery ajax get return value

后端 未结 7 1597
不知归路
不知归路 2021-01-21 04:22

i want to get the \'printed value\' of html pages.

i tried below query, but showGetResult() just return \'null value\'

but my apache server logs printed i access

7条回答
  •  灰色年华
    2021-01-21 04:38

    AJAX requests are aynchronous by default; you can't return their result in a function, you need to use callbacks. The easiest way to achieve what you want is to put your code that handles your data in your success handler:

        success:function(data)
        {
            alert(data);
            result = data;
            document.write(showGetResult('test'));
        } 
    

    Also, don't use document.write.

提交回复
热议问题