php - .ajax() not responding after keyup event -
this jquery/ajax problem. jquery/ajax responding keyup event alert(loc) showing result of value inputted number textbox.
the essense of program data database in array form after encoding json via php , display result inside textbox.
however, reaching .ajax function, not display inside success section. @ end, there no response or error. used jsonlint see if there error, gave code dont understand.
afte using mozilla firebug step through jquery, still did not show message.
this html,php,jquery codes verification.
js: $(document).ready(function() { $('#number').keyup(function() { //keyup event responds var loc = $('#number').val(); alert(loc); //display result number textbox $.ajax({ //skips ajax function datatype: "json" url: "/php/barry.php", data: ({loc : loc}), async: false, type: "get", contenttype: "application/json; charset=utf-8 success: function(data) { $.each(data.result, function() { $("#number").append(this['number']);// suppose display $("#name").append(this['name']); }); } }); }); }); php: <?php include_once('/db.php'); if(isset($_get['loc'])){ $foo = $_get['loc']; $sql = "select * freak number='$foo'"; $res = mysql_query($sql); $result = array(); while( $row = mysql_fetch_array($res) ) array_push($result, array('number' => $row[0], 'name'=> $row[1]; //print_r($result); echo json_encode(array("result" => $result)); } ?>
Comments
Post a Comment