从SQL选择到PDO

My previous SQL SELECT code worked with this AJAX request, but I want to convert it to PDO statements.

JavaScript

$.ajax({  
    type: "POST",  
    url: "ajax.php",  
    data: "mail="+ mail,  
    success: function(msg){  
    if(msg == 'mail already in use'){
    ....  

ajax.php

$dsn = "mysql:host=localhost;dbname=vedic;charset=utf8";
$opt = array(
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$pdo = new PDO($dsn,'root','', $opt);

if(isset($_POST['mail'])){
$mail = $_POST['mail'];

$stm = $pdo->prepare("select id from members where email='$mail'");
$stm->execute(array($id));
$name = $stm->fetchColumn();

What now? How can I get the result which I can use in AJAX?

You are supposed to understand what you are reading, not just copy-paste it.
Look what have you read:

Using prepared statements is the main reason to use PDO.
Every dynamic data literal has to be represented in a query by either name (:name) or regular placeholder (?).

But what did you do? Kept your data inserted in a query directly:

$stm = $pdo->prepare("select id from members where email='$mail'");

Why not to make this code using placeholder?

and what now ?

Fix your code to make it sensible and working.

How can I get the result which I can use in ajax?

The code you posted is already supposed to take the desired value, which you can use anywhere you wish.

Please take a little time investigating this code, playing with it, making yourself familiar with it. Bear in mind that this site is not a free coding service. A code from answer is not necessarily have to be working out of the box. An answer supposed to give you an idea, not do your job.