Cita:
Iniciado por elarrieux
Podremos ver el codigo?
Estas haciendo alguna conversion en la llamada al ajax? Asignando content type al ajax?
Sds.
Ok, estos son los archivos que utilizo:
Index.html
Código HTML:
Ver original<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<body style="text-align: center;"> <div style="text-align: left; width: 500px; margin: 0 auto;"> <form action="" method="post" accept-charset="UTF-8" name="postedit"> <div style="float:left; color:#0D7200; font-weight: bold; margin-bottom:3px;"> <div style="display:inline-block; margin-left:5px;"> Categoria:
<div style="display:inline-block; margin-left:5px;"> <input id="EditCategoria" class="inputPublicar" style="height: 20px; margin-left: -5px;" type="text" maxlength="25" value="Música"> <input class="login" type="submit" style="float:right;" name="postEdit" id="postEdit" value="Guardar" onclick="return Guardar(this.form.EditCategoria.value);" tabindex="2">
acciones.js
Código Javascript
:
Ver originalfunction Guardar(categoria)
{
if(categoria == "")
{
alert("Ingresa una categoria");
return false;
}
else
{
$.ajax({
type: 'POST',
url: 'http://localhost/pagina/Guardar.php',
data: 'categoria='+ encodeURIComponent(categoria),
success: function(h){
$("#EditCategoria").val(h);
},
error: function(){
}
});
return false;
}
}
Guardar.php
Código PHP:
Ver original<?php
$categoria = $_POST['categoria'];
//Limpiar
$categoria = preg_replace("/[^a-z ñáéíóú]/i", "", $categoria);
echo $categoria." *";
?>