Xtremer360 Posted June 2, 2012 Share Posted June 2, 2012 I"m trying to find out if this is really a PHP issue or jQuery issue. After it does the POST request it sends this as a parameter: username testusername In the response I get this: <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"> <h4>A PHP Error was encountered</h4> <p>Severity: Warning</p> <p>Message: Missing argument 1 for Register::isUsernameAvailable()</p> <p>Filename: controllers/register.php</p> <p>Line Number: 118</p> </div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"> <h4>A PHP Error was encountered</h4> <p>Severity: Notice</p> <p>Message: Undefined variable: username</p> <p>Filename: controllers/register.php</p> <p>Line Number: 120</p> </div>{"username":"notfound"} PHP public function isUsernameAvailable($username) { if ($this->usersmodel->isUsernameAvailable($username)) { echo '{"username":"found"}'; } else { echo '{"username":"notfound"}'; } } jQuery $('#username').blur(function(){ $.post('register/isUsernameAvailable', {"username":$(this).val()}, function(data){if(data.username == "found"){alert('username already in use');}}, 'json'); }); Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/ Share on other sites More sharing options...
silkfire Posted June 2, 2012 Share Posted June 2, 2012 Show us the code where you call the isUsernameAvailable() function instead. Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350635 Share on other sites More sharing options...
Xtremer360 Posted June 2, 2012 Author Share Posted June 2, 2012 That's it inside the jQuery code. Once the user gives input into the username field then a post is done to the php. Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350649 Share on other sites More sharing options...
silkfire Posted June 2, 2012 Share Posted June 2, 2012 That's JavaScript code made, whom are you trying to fool? Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350650 Share on other sites More sharing options...
Xtremer360 Posted June 2, 2012 Author Share Posted June 2, 2012 I said it was jQuery. Are you not reading my posts. Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350651 Share on other sites More sharing options...
Xtremer360 Posted June 2, 2012 Author Share Posted June 2, 2012 I showed you PHP code and jQuery code. Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350652 Share on other sites More sharing options...
silkfire Posted June 2, 2012 Share Posted June 2, 2012 You showed us the function definition. It's like buying concert tickets and not going to the concert. Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350655 Share on other sites More sharing options...
silkfire Posted June 2, 2012 Share Posted June 2, 2012 Quote I said it was jQuery. Are you not reading my posts. jQuery is a subset of JS. Any jQuery code is also JavaScript code, but not necessarily vice versa. Link to comment https://forums.phpfreaks.com/topic/263547-posting-with-json/#findComment-1350657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.