jquery - Parameters and AJAX, PHP -


i'm trying retrieve information php page queries database based on ?id= parameter given. doing via ajax should give user information on specific item etc. if id parameter not exist within database, user redirected lookup page.

when looking @ ajax examples , following same steps seem parameter isn't being used mysql query - it's using header information redirect me , retrieve lookup page if incorrect value given id exists.

any ideas on what's going wrong?

var id = $('#code').val; input users supply id wish lookup.

$(document).ready(function() { $('#check').click(function() {     var id = $('#code').val;     if (id=="")       {       document.getelementbyid("result").innerhtml="";       return;       }      if (window.xmlhttprequest)       {       xmlhttp=new xmlhttprequest();       }     else       {       xmlhttp=new activexobject("microsoft.xmlhttp");       }     xmlhttp.onreadystatechange=function()       {       if (xmlhttp.readystate==4 && xmlhttp.status==200)         {         document.getelementbyid("result").innerhtml=xmlhttp.responsetext;         }       }     xmlhttp.open("get","result.php?id="+id,true);     xmlhttp.send(); }); }); 

further developerck mentioned regarding jquery syntax error in line:

var id = $('#code').val;  // should be: var id = $('#code').val(); 

you can save lot of typing switching jquery syntax ajax requests. here posts getting started jquery/ajax:

a simple example

more complicated example

populate dropdown 2 based on selection in dropdown 1


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -