Страница регистрации FB должна выглядеть следующим образом
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#appId=134552926621785&xfbml=1"></script>
<fb:registration redirect-uri="http://dev2.urecommendme.com/test3.aspx"
fields='[{"name":"name"},
{"name":"username","description":"Username","type":"text"}]'
onvalidate="validate_async"></fb:registration>
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>
function validate_async(form, cb) {
$.getJSON('test02.aspx?username=' + form.username,
function (response) {
if (response.error) {
// Username isn't taken, let the form submit
cb();
}
cb({ username: 'That username is taken' });
});
}
</script>
</body>
Обратите внимание, как я упомянул имя файла сервера (оно не содержит полного URL-адреса, так как оба файла были в одном корневом каталоге) в функции validate_async (form, cb)
$.getJSON('test02.aspx?username=' + form.username,
Страница Test02.aspx должна выглядеть следующим образом
Обратите внимание на отсутствие тегов html, body или head в test02.aspx
(Test02.aspx.cs) должен выглядеть как
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using System.Text;
public partial class test02 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e1)
{
StringBuilder JSON = new StringBuilder();
//validate from your database and execute one of the following two lines.
JSON.Append("{\"error\":\"Exist\"}"); // username is taken
// JSON.Append("{\"anything\":\"Not Exist\"}");
Response.Write(JSON.ToString());
Response.End();
}
}