I am using Buddy.com's API to build a mobile app with a web Interface for Administrators and User Creation. I am still in the initial stages of this project.
The first page I am trying to build is the User Registration page for the website.
This page will have a form asking the users for a username, password, email and some other fields.
I am using the javascript form the page http://buddy.com/developers/#UserAccount_Profile_Create
The function is: function createUserWithName(); And it has some inputs. The function looks like this:
function fixedEncodeURIComponent (str) {
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
}
function createUserWithName(aName, anEmail)
{
var finalURLStr = https://webservice.buddyplatform.com/Service/v1/BuddyService.ashx;
finalURLStr += ?UserAccount_Profile_Create; // API Call
finalURLStr += &BuddyApplicationName= + fixedEncodeURIComponent(<#Buddy App Name#>);
finalURLStr += &BuddyApplicationPassword= + fixedEncodeURIComponent(<#Buddy App Password#>);
finalURLStr += &NewUserName= + fixedEncodeURIComponent(aName); // The user name
finalURLStr += &UserSuppliedPassword= + fixedEncodeURIComponent(<#password#>); // User password
finalURLStr += &NewUserGender= + male; // male or female
finalURLStr += &UserAge= + 29; // user age (int)
finalURLStr += &NewUserEmail= + fixedEncodeURIComponent(anEmail); // user email
finalURLStr += &StatusID= + -1; // see status table (1-7 or -1)
finalURLStr += &FuzzLocationEnabled= + 1; // true / false: location isn't/is reported accurately
finalURLStr += &CelebModeEnabled= + 0; // true if user is hidden from non-friends
finalURLStr += &ApplicationTag=; // app-related info
finalURLStr += &RESERVED=; // leave empty
$.ajax({ url: finalURLStr })
.done( function(data) {
// Result is a simple string
alert(Result: + data);
})
.fail(function() {
alert(Error while contacting Buddy!);
});
}
I have created a form which asks for the user to input this information.
How can I pass the field data from my form to this function?
This is the code for my form:
<form id=register>
<table width=200 border=0 cellspacing=0 cellpadding=0>
<tr>
<td><label for=username>Username*:</label>
<input type=text id=username name=username />
</td>
</tr>
<tr>
<td><label for=password>Password*:</label>
<input type=text id=password name=password />
</td>
</tr>
<tr>
<td><label for=email>Email*:</label>
<input type=text id=email name=email />
</td>
</tr>
<tr>
<td><label for=gender>Gender*:</label>
<select id=gender>
<option value=null>Please Choose One...</option>
<option value=Male>Male</option>
<option value=Female>Female</option>
</select>
</td>
</tr>
</table>
<input class=button name=submit type=button value=submit onclick=createUserWithName(username.value) />
</form>
Im sure that once someone shows me how to send the username and email to the javascript function I will be able to figure out the rest.
Thank you