php - JQuery AJAX update a textbox on another textbox textchanged -


i update input text type (id="textbox2") when typed @ input text type (id="textbox1").

here's initial code:

$("#textbox1").keyup(function(){        $.ajax({             type: "post",             url: "idgetter.php",             data: 'id='+$("#textbox1").val(),             success: function(n) {                 $('#textbox2').val(n);             },             error: function(n) {                 $('#textbox2').val(n);             }         });      }); 

and idgetter.php :

include("inc/conn.php"); $q = mysql_query("select name jurnalis userid = '".$_post['id']."'")or trigger_error("sql", e_user_error); if(mysql_num_rows($q)<=0) return "none"; else{ $r = mysql_fetch_array($q); return $r["name"]; 

long story short, did not work, idea why?

in idgetter.php, instead of returning using return give

echo "none"; 

and

echo $r["name"]; 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -