Ajax response html
3 posters
Page 1 of 1
Ajax response html
- Code:
var id = '10' //<--- change the id
$.get('/u' + id , function (e) {
console.log(e); //<--- all html tree
});
since e is a html but we can not not user getelementbyid, getelementbyclass .. etc.
Is anyway we can use those functions to get the value ??
Last edited by TamDonCo on September 26th 2016, 2:26 am; edited 1 time in total
Re: Ajax response html
$.get is from jquery library is a shorthand of XMLHttpRequest, also it's not possible use directly javascript for catch elements
https://xhr.spec.whatwg.org/
if you learn call data with XMLHttpRequest pure, it is possible use javascript pure or vanilla
you can do this:
https://xhr.spec.whatwg.org/
if you learn call data with XMLHttpRequest pure, it is possible use javascript pure or vanilla
you can do this:
- Code:
var id = '104367';
$.get('/u' + id , function (e) {
var document = $('#wrap', e)[0];
b = document.innerHTML;
c= document.getElementsByClassName('panel')[0].textContent;
console.log('panel html: '+ c);
});
Ch@lo Valdez- Forumember
- Posts : 138
Reputation : 50
Language : spanish
Re: Ajax response html
ok, with javascript:
try
use this way:
- Code:
function loadDoc(url, cfunc) {
var xhttp;
xhttp=new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
cfunc(this);
}
};
xhttp.open("GET", url, true);
xhttp.responseType = 'document';
xhttp.send();
}
function ajaxsetup(xhttp) {
AjaxDocument = xhttp.responseXML;// <--- document
}
|
try
|
use this way:
|
Ch@lo Valdez- Forumember
- Posts : 138
Reputation : 50
Language : spanish
Re: Ajax response html
Thanks Ch@lo Valdez again
both work fine, the first one is simpler, the second one í more formal ..
both work fine, the first one is simpler, the second one í more formal ..
Re: Ajax response html
Problem solved & topic archived.
|
Similar topics
» .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!
» How to Embed a Google Docs Form into an HTML page using HTML Pages Management
» Ajax script seems not to work anymore
» Ajax loading script problem
» Ajax reply - all versions
» How to Embed a Google Docs Form into an HTML page using HTML Pages Management
» Ajax script seems not to work anymore
» Ajax loading script problem
» Ajax reply - all versions
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum