ajax - Modify javascript to get TWO query strings -
i have javascript code sends value of entered in input bar php file fetches rows database according value of entered input field. need edit code javascript not sends value of being entered input bar php, javascript variable.
the code follows:
function showfriends(str) { var cake = document.getelementbyid("cake"); if(str.length == 0) { document.getelementbyid("livesearch1"). innerhtml = ""; document.getelementbyid("livesearch1"). style.border="0px"; return } xmlhttp=getxmlhttpobject() var url="petition_send.php" url=url+"?q="+str url=url+"&sid="+math.random() xmlhttp.onreadystatechange=statechanged xmlhttp.open("get",url,true) xmlhttp.send(null) } function statechanged() { if(xmlhttp.readystate == 4 || xmlhttp.readystate=="complete") { document.getelementbyid("livesearch1"). innerhtml=xmlhttp.responsetext; document.getelementbyid("livesearch1"). style.border="1px solid #a5acb2"; } } function getxmlhttpobject() { var xmlhttp=null; try { //firefox, opera 8.0+, safari xmlhttp=new xmlhttprequest(); } catch (e) { //internet explorer try { xmlhttp=new activexobject("msxml2.xmlhttp"); } catch (e) { xmlhttp=new activexobject("microsoft.xmlhttp"); } } return xmlhttp; }
i need var url equivalent "petition_send.php?petition_id=cake&"
but, reason, code doesn't work when write that.
any thoughts?
if jquery option can use like
$("#mybutton").click(function(){ $("#livesearch1").load("petition_send.php", { "q" : $("#cake").text(), "sid" : math.random() }).css("border","0px"); });
which lot simpler
Comments
Post a Comment