I'm having a lot of trouble with getting this code working:
<script type = "text/javascript">
jQuery(document).ready(function($){
$('#submitbutton').click(function(){
var email=document.getElementById('emailadd').value;
var password=document.getElementById('pass').value;
$.ajax({
type: "POST",
url: "/wp-content/themes/roots-master/login.php",
data: {emailaddress:'email', password:'password'},
dataType: "text",
success:function(response){
alert("success");
}
});
});
});
</script>
When I comment out the $.ajax function, the javascript works fine(I tested it with an alert). However, the $.ajax part doesn't seem to be working. Does anybody have any suggestions?
When I change the code to the following, the javascript appears to not work as well:
$('#submitbutton').click(function(){
var email=document.getElementById('emailadd').value;
var password=document.getElementById('pass').value;
$.ajax({
alert(password);
});
});
I am using wordpress so I didn't put any links to jquery in the head. Instead, I put the following into my functions.php and then jquery started working.
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery /1/jquery.min.js', false, '1.9.1', false);
wp_enqueue_script('jquery');
UPDATE: For some reason, when I put an alert after the $.ajax, it works!
jQuery(document).ready(function($){
$('#submitbutton').click(function(){
var email=document.getElementById('emailadd').value;
var password=document.getElementById('pass').value;
$.ajax({
dataType: "html",
type: "POST",
evalScripts: true,
url: "/wp-content/themes/roots-master/login.php",
data: {emailaddress:'email', password:'password'},
dataType: "text",
success:function(){
alert("success");
}
});
alert("testing");
});
});
Does anyone know why this would be?