javascript - send a variable to php with AJAX -



javascript - send a variable to php with AJAX -

how can send rownumber variable datasource php file in code ?

function getdata(datasource, divid,rownumber) { if(xmlhttprequestobject) { var obj = document.getelementbyid(divid); xmlhttprequestobject.open("get", datasource); xmlhttprequestobject.onreadystatechange = function() { if (xmlhttprequestobject.readystate == 4 && xmlhttprequestobject.status == 200) { obj.value = xmlhttprequestobject.responsetext; } } xmlhttprequestobject.send(null); } }

php file (datasource):

<?php //mysql connection $result = mysql_query( 'call view_polls(`rownumber`);' ); $row=mysql_fetch_array($result); echo $row['title']; ?>

function getdata(datasource, divid,rownumber) { if(xmlhttprequestobject) { var obj = document.getelementbyid(divid); xmlhttprequestobject.open("get", datasource + "?rownumber=" + rownumber); xmlhttprequestobject.onreadystatechange = function() { if (xmlhttprequestobject.readystate == 4 && xmlhttprequestobject.status == 200) { obj.value = xmlhttprequestobject.responsetext; } } xmlhttprequestobject.send(null); } }

php:

<?php if (isset($_get['rownumber']) && is_numeric($_get['rownumber'])) { $rownumber = $_get['rownumber']; //mysql connection $result = mysql_query( 'call view_polls(`' . $rownumber . '`);' ); $row=mysql_fetch_array($result); echo $row['title']; } else { echo "error"; } ?>

php javascript ajax xmlhttprequest

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -