javascript - Ajax request -> request.readyState problems -


i cannot execute php on page, because content stored in mysql database, can put javascript/jquery/ajax.

i need few details page can dynamic. built php script output data needs in string this:

 string=value|string2=value here|string3=value there 

it on same domain, not cross urls...

here ajax i'm trying use, code have on website created few years ago, cannot work, i'll share code , response seeing below.

code load on page out of database:

function createrequest() {     try {         request = new xmlhttprequest();     } catch (tryms) {         try {             request = new activexobject("msxml2.xmlhttp");         } catch (otherms) {             try {                 request = new activexobject("microsoft.xmlhttp");             } catch (failed) {                 request = null;             }         }     }     return request; }   function cpf(tpg) {     request = createrequest();     if(request == null) {         alert("unable create request");         return;     }     var nocache = new date();     var url = "/pull_data.php?t=" + tpg;     url = url + "&stopiecache="+ nocache;      request.open("get",url,true);     request.onreadystatechange = showtpage();     request.send(null);     return true; }  function showtpage() {     if(request.readystate == 4) {         if(request.status == 200) {             detaildiv = document.getelementbyid("showpagehere");             detaildiv.innerhtml = request.responsetext;         } else {             alert('req failed...');         }     } else {         alert('request failed.' + request.readystate);     } } 

i put link on page calls this:

<a href="javascript:void(0)" onclick="if(cpf(customdata)) {alert('ran , customdata = ' + customdata);} else {alert('pow, did not work... hmm');}">click here run code</a><br /> <div id="showpagehere"></div> 

customdata set elsewhere, , alert me of data, populated...

the second alert code, has this:

request failed. 1 

so response 1

do see why not working?

because php file calls on same url, lost why not working.

i appreciate helping me find error, i've worked on past weekend, on 20 hours, , cannot figure out.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -