im working with jquery.get, im sending to a php file a quest of the numbers of rows of a data base table, and the value that returns its correct, i can work with that inside the funcion jQuery.get, but i dont know how to work with that variable out of .get, i mean, i dont know how to pass out the variable, i tried with oop like this:
function contarRegistros(){
this.num=1;
this.contar = function (tabla){ $.get("numeroRegistros.php",{tab:tabla},function(dato){
contarr.setNum(dato); });
}
this.setNum = function (numero){ contarr.num = numero; }
hi, im trying to make a application, im trying to comunicate with the server with the function load, but it doesnt work, also i try with $.ajax, $.get, but nothing works, i have 3 files, html file, php file and javascript with jquery file, here are the php and javascript files:
javascript: var x; x=$(document); x.ready(iniciar);
function iniciar(){ var x; x=$("#boton"); x.click(pasarNombre); }
var nombre; var conexion2; function pasarNombre(){ nombre=$("#nombre").attr("value"); alert(nombre); var conexion=$("#status"); conexion.text("aqui si"); alert("status"); //$.get("verificarNombre.php",{nomm:nombre},escribir); //conexion.ajaxStart(escribir); //conexion.load("verificarNombre.php?nomm="+nombre); $.ajax({ async:true, type: "GET", dataType: "html", contentType: "application/x-www-form-urlencoded", url:"verificarNombre.php", data:"nom="+nombre, beforeSend:escribir, success:llegadaDatos, timeout:40, error:problemas });
return false; }
function escribir(){ var s =$("#status"); s.html("Verificando..."); }
function llegadaDatos(nombre){ $("#status").text(nombre); }
function problemas(){ $("#status").text('error'); }
php:
<?php $conexion = mysql_connect("localhost","root","") or die("Problemas en la conexion");
mysql_select_db("tequila",$conexion) or die("Problemas en la seleccion de la base de datos");
$nombres=mysql_query("select nombre from usuario",$conexion) or die("Problemas en el select".mysql_error());
$nom=$_REQUEST['nombre']; $ban = false;
while($reg=mysql_fetch_array($nombres)){ if($reg['nombre']==$nom){ $ban=true; } } if($ban){ echo "El nombre esta ocupado"; } if($ban!=true){ echo "El nombre esta disponible"; } ?>