Jump to content

Recommended Posts

thank you it works, but I have little concern, I want to associate in the same file js validation and ajax function. instead of executing all the code, it runs a single

Share this post


Link to post
Share on other sites
On 5/16/2019 at 7:09 AM, dsonesuk said:

As only YOU! Have access to the code, I should think you did something wrong. 

 

Share this post


Link to post
Share on other sites

this is my query code 

 

$(document).ready(function(){
$('#submit').click(function(event){
 
event.preventDefault();
var name = $('#name').val();
var email = $('#email').val();
if(name == '' || email == '')
{
$('#error_message').html("Tous les champs sont obligatoire");
}
else
{
$('#error_message').html('');
$.ajax({
type:'POST',
url:'connexion.php',
data:{name:name, email:email},
success:function(data){
$("form").trigger("reset");
$('#success_message').fadeIn().html(data);
setTimeout(function(){
$('#success_message').fadeOut("Slow");
}, 2000);
 
}
 
});
}
 
});
});
,
 
$(function(){
 
$('#formu').validate({
rules:{
email:{
required:true,
email:true



 
}
 
}


 
});


 
});
 
</script>
 



 

Share this post


Link to post
Share on other sites

Check your browser's error console, you have random punctuation in there.  You should really make an effort also to keep your code formatted and indented without a bunch of extra lines so that it's easy to read.

Share this post


Link to post
Share on other sites

You can put as many functions coding within a file as like as long as they have access to all required resources to run and is correct so it does not break functionality of code following it.

Share this post


Link to post
Share on other sites

Did you fix the syntax error in your code above?  The reason it doesn't work is because you have a syntax error.  That's why you need to look at your browser's developer console to see the error message.

Share this post


Link to post
Share on other sites

It will help if you answer questions that we ask.  Are you looking at your browser's developer console?  Do you see the error message?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...