本文介绍了获取HTML code。使用JavaScript的一个网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用xmlhtt prequest的URL得到HTML源$ C $ C。是否有任何人谁可以帮助我?我是新来编程,我也不太清楚我该怎么做没有jQuery的。先谢谢了。
I am trying to get the source code of html by using a xmlhttprequest with a url. Is there anyone who can help me with this? I am new to programming and I am not too sure how can I do it without jQuery. Thanks in advance.
推荐答案使用jQuery
$.ajax({ url: 'your-url', success: function(data) { alert(data); } });
数据是你的HTML
data is your html
没有的jQuery
function makeHttpObject() { try {return new XMLHttpRequest();} catch (error) {} try {return new ActiveXObject("Msxml2.XMLHTTP");} catch (error) {} try {return new ActiveXObject("Microsoft.XMLHTTP");} catch (error) {} throw new Error("Could not create HTTP request object."); } var request = makeHttpObject(); request.open("GET", "your_url", true); request.send(null); request.onreadystatechange = function() { if (request.readyState == 4) alert(request.responseText); };更多推荐
获取HTML code。使用JavaScript的一个网址
发布评论