JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 28th, 2012, 09:59 AM
jaimitoc30 jaimitoc30 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 37 jaimitoc30 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 44 m 41 sec
Reputation Power: 1
jQuery - JQuery, AJAX and JSON simple question

Hi, I am starting to learn jQuery, AJAX and JSON. I am trying to pass a variable to a PHP script called validate_user.php using the jQuery, AJAX, JSON technique. I keep getting the error SyntaxError: JSON.parse: unexpected character. I have tried a lot of ways to make it work.. and this is the code for the ajaxSubmit.js

Code:
$(document).ready(function(){
$('#loginbutton').click(function() {
$('#waiting').show(100);
$('#login-box').hide(0);
$('#message').hide(0);

$.ajax({
type: 'POST',
url: 'validate_user.php',
//data: {usuario : $('#usuario-field').val(), password : $('#usuario-password').val() },
data: {'usuario' : 'prueba', 'password' : 'pruebapass' },
dataType : 'json',
success : function(data){
$('#waiting').hide(500);
$('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
.text(data.msg).show(500);
if (data.error === true) 
$('#login-box').show(500);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
$('#waiting').hide(500);
$('#message').removeClass().addClass('error')
.text('There was an error.').show(500);
$('#login-box').show(500);
}
});
 
return false;
});
});


Can someone help me out, please? I tried to read on Google and resolve this yesterday, I am still reading today, but now I feel I need some assistance, don't know where exactly is the syntax error, hope it is something simple and some experienced user can help me with this. Regards.

Reply With Quote
  #2  
Old November 28th, 2012, 10:18 AM
jaimitoc30 jaimitoc30 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 37 jaimitoc30 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 44 m 41 sec
Reputation Power: 1
Quote:
Originally Posted by jaimitoc30
Hi, I am starting to learn jQuery, AJAX and JSON. I am trying to pass a variable to a PHP script called validate_user.php using the jQuery, AJAX, JSON technique. I keep getting the error SyntaxError: JSON.parse: unexpected character. I have tried a lot of ways to make it work.. and this is the code for the ajaxSubmit.js

Code:
$(document).ready(function(){
$('#loginbutton').click(function() {
$('#waiting').show(100);
$('#login-box').hide(0);
$('#message').hide(0);

$.ajax({
type: 'POST',
url: 'validate_user.php',
//data: {usuario : $('#usuario-field').val(), password : $('#usuario-password').val() },
data: {'usuario' : 'prueba', 'password' : 'pruebapass' },
dataType : 'json',
success : function(data){
$('#waiting').hide(500);
$('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
.text(data.msg).show(500);
if (data.error === true) 
$('#login-box').show(500);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
$('#waiting').hide(500);
$('#message').removeClass().addClass('error')
.text('There was an error.').show(500);
$('#login-box').show(500);
}
});
 
return false;
});
});


Can someone help me out, please? I tried to read on Google and resolve this yesterday, I am still reading today, but now I feel I need some assistance, don't know where exactly is the syntax error, hope it is something simple and some experienced user can help me with this. Regards.


If someone is interested what was the issue, actually it was an issue with the validate_user.php file. I ran that on my browser and the script had something incorrect, so that was causing the issue

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - JQuery, AJAX and JSON simple question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap