There are a few. The $.ajax methods will end up doing 90% of your
work. I'll show you a pretty quick process demonstrating checking if
an email address is registered.

First, the PHP servlet page, check-email.php:
<?php
   echo json_encode(
      array('success' => mysql_num_rows( mysql_query( 'SELECT * FROM
`user_emails` WHERE `email` = "'. $_REQUEST['email'] .'" LIMIT 1' ) )
== 0 ? true : false)
   );
?>

Now the HTML:

<label>Enter your desired eMail account name to check availability</
label>
<input id="user-email" type="text" size="15"/>
<span id="status" style="display:none"></span>
<button id="submit" value="Check Now">Check Now</button>

And finally the jQuery

$(function(){
   $('#submit').click(function(){
      $.get('check-email.php', {email: $('#user-email').val()},
function(data){
         var status = $('#status');
         if (data.success) status.text('eMail is Available!').css
('color', 'green');
         else status.text('eMail is NOT Available!').css('color',
'red');
      }, 'json');
   });
});

I hope that gave you kinda an idea of how you can use jQuery for RPCs.




On Mar 23, 11:55 am, "!oEL" <runzhou...@gmail.com> wrote:
> Hi,
>
> I'm really new to JS, but really like how AJAX simplifies the user
> interface experience.
>
> Some friends have recommended a variety of JS Lib/Frameworks, and I
> eventually decided to pick jQuery after glancing through its
> documentation.
>
> Now I want to try it out together with PHP to implement remote
> procedures calls in order to interact with a database (namely, MySQL)
> for an application.
>
> So how easy is it to achieve this, are there any good built-in methods
> that simplifies this work?
>
> Thank you :)
>
> !oEL

Reply via email to