is it possible to "catch" a php-varibale ?
Sorry if the title scared you, don't know how i'm suppose to phrase it.
Ok so i'm looking into the $.ajax() function. Very interesting stuff.
i'm just practicing to learn and to do that i have this form, just name and email, i want to send it to a DB. so i do the following:
-
$(function() {
$(".button").click(function() {
var name = $("input#name").val();
var email = $("input#email").val();
var phone = $("input#phone").val();
var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "bin/process.php",
data: dataString,
success: function() {
$('#contact_form').html("<div id='message'></div>");
$('#message').html("<h2>eureka!</h2>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='images/check.png' />");
});
}
});
return false;
});
});[/quote]
ok so that i get, BUT if there is a problem with the insert-query it would still show the "success-box". That's not what i was aiming for so,
i am looking for a way to get a php-variable into my js-script
what i would like to do is to add a variable in my php script named $ok.
i would than like to check with Jquery if $ok == 1 if so show the successbox, otherwise show an other box with e.g. the mysql-error. Is this possible or not and if so, how please ?