score:0
Accepted answer
Not sure if this was the best solution, but it works as it should do.
<input id="submit" type="submit" value="Submit">
if email found:
echo '<script> $(document).ready(function() { $("#submit").attr("disabled", "disabled"); }); </script>';
if email not found:
echo '<script> $(document).ready(function() { $("#submit").removeAttr("disabled"); }); </script>';
It works :-)
score:0
You can work whitout submit button perfectly, with a button type="button"
. I think you are looking for something like this:
function check_email_ajax(e_mail){
$("#email-result").html('<img src="../cms/assets/images/loading.gif" width="20px" height="20px" />');
$.post('ajax/register.ajax.php', {'email':e_mail}, function(data) {
$("#email-result").html(data);
var result= $("i").attr("id")
if (result==red){
//If this is the result you stay on the page and user see the red message :)
}
if (result==green){
//If result is green I imagine you want to go where the action in form tag says, so delete action from the form, you can simply redirect where you want:
url = "your-file.php"
$(location).attr("href", url)
}
});
}
Add a id for icons:
if($statement->fetch()){
die('<i class="fa fa-times-circle" id="red" style="color:red;" aria-hidden="true"></i> <small>(taken)</small>');
}else{
die('<i class="fa fa-check" id ="green" style="color:green;" aria-hidden="true"></i> <small>(Yeey :-) )</small>');
}}
Hope it helps you.
Related Query
- How to pass a string containing back slash and front slash from PHP query page back to JavaScript using AJAX
- html / javascript: Prevent <input> value from clearing on form submit
- Rails 3: submit Remote form via jQuery - prevent page from reloading
- Cannot Modify/Manipulate Dynamic Content From Ajax/JSON Response for A Dynamic PHP Form
- Getting data from PHP page on form submit
- Best Practice for submitting a JSF 2 form that might use ajax if we have an error response from the submit
- jQuery ajax form submission to php not working with response from server
- Form using PHP & JQuery auto populates fields after form submit
- $.ajax error getting back data from php file
- Loading a php snippet on a modal with an ajax call and posting from the form causing to call it multiple times
- Prevent Page Refresh From a Submit Button for jQuery Mobile
- Using JQuery to get JSON response from PHP
- Execute ajax request on form submit and don't wait for response
- append response from ipinfo.io to contact form message
- Using php & jquery to post data from textboxes to text (csv) file and verify this by reading back to different textboxes on same webpage
- Submit form from popup window javascript
- Use jquery to copy form from lightbox window back to parent page
- When submit the form, if the checkbox isn't checked, shows the tips and prevent the form submitted
- How to prevent click event from firing when turning it back "on" with jQuery?
- Submit HTML Form with fields and file using Ajax and php
- jquery loading animation with php form that submits back to itself
- jquery loading animation with php form that submits back to itself
- Jquery PHP form submit - How to get form inputs to display?
- Dynamically add equal select form fields with data taken from php
- Evenly Rotate And Check And Then Submit The PHP Form
- How to hide a email form when it gets response from JSON
- Passing form ID's as a variable back and forth between javascript and php
- how can I access my json encoded data from PHP into a mysql query
- Loading template with variables from form fields using jQuery & php
- Ajax gets nothing back from the php
- How can I use json response from php in jquery?
- Get the button that caused the submit from the form submit event
- prevent page reload on form submit on button click
- JQuery ajax form submit for return file giving undefined error response
- Ajax response from php POST
- Unable to update div text from ajax response sent via php
- Ajax show response from php file after file upload
- Prevent html form submit while uploading file in jQuery-File-Upload plugin
- Replacing the form with the return value from a php function using ajax
- FancyBox PHP form submit issue
- getting response from php page to ajax?
- Submit form with ajax and hide the from on sucess
- Receiving response from PHP via AJAX
- Prevent page getting refreshed on form submit via JQuery
- ajax response from PHP file
- How do I prevent users from changing form values or removing input fields elements using inspector tool?
- Post back variable from PHP to JS after POST?
- Prevent Form from Submitting if there are Errors
- Send a form from Jquery to PHP with ajax (wordpress)
- Reset the Html Form after form submission and prevent user to come back and see the submitted data
More Query from same tag
- How can I get the text of a label using Jquery in this particular case ?
- confused with attr to use with mouseover() and mouseout()(image swap)
- How to count duplicate array elements? (javascript)
- jquery select class
- Fire jquery animate on same element while animation is in progress
- getting a value out of show.bs.collapse twitter bootstrap
- jQuery Draggable area (Circle)
- Slow animate() in safari 5.1.7, but fine in firefox and chrome
- Showing error message using jQuery and making it disappear
- jQuery Form Validate() - Default Text
- using href to two links(php and a webpage)
- jQuery .click() firing ONLY at load
- JQuery and IE7-none of my selectors seem to be working
- How to access HTML element attribute in jQuery JSON
- JQuery JConfirm not working with UIWebview on iOS
- Detect a textbox's content has changed after date selection
- how to get only time from datetime like(2011-04-23 09:30:51:01) in java or javascript or jquery
- Javascript request over XHR
- Stopping propagation on multiple hover event
- Clone table row and math function in jquery - how to correctly tackle?
- javascript get datepicker start or end value of attribute
- Legend in horizontal multi bar chart
- Jquery select selector - Jsfiddle example
- jQuery how to dynamically add select element and reset choice?
- Iterating Over <select> Using jQuery + Multi Select
- url fragment issue with angularjs router and jquerys sizzle
- change parent child related ids of nested objects
- How to check upload speed in javascript?
- jsviews: How to trigger model data update on form submit instead of onkeydown
- prevent continue for loop when jquery ajax until load