The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
registration using xhr
Hey,
I'm trying to implement registration with ajax/xhr request: Code:
$.post({ url: './register.php?do=addmember', data: formData, success: function(res) { console.log(res); }, dataType: 'html', processData: false, contentType: false, }); The user is successfully registered yet when I am refreshing the page, I am not logged in. The session cookie is set successfully as well. When I try to register the usual way, everything works fine. What am I missing? is there something needed in the server side after the registration to acknowledge the cookie ? Any help will be appreciated. |
#2
|
|||
|
|||
I've done it successfully with XHR, If someone else will need to do this, here is an example code :
Code:
var xhr = new XMLHttpRequest(); var formObjData = { timezoneoffset: 2, dst: 2, 'options[adminemail]': 1, 'options[showemail]': 1, do: 'addmember', password: $("input[name='password']")[0].value, passwordconfirm: $("input[name='passwordconfirm']")[0].value, username: $("input[name='username']")[0].value, agree: $("#agree")[0].checked, email: $("input[name='email']")[0].value, emailconfirm: $("input[name='email']")[0].value, securitytoken: 'guest' }; var strObj = ''; for (var k in formObjData) { if (formObjData.hasOwnProperty(k)) { var val = formObjData[k]; strObj = strObj + `${k}=${val}&`; } } strObj = strObj.slice(0, strObj.length - 1); xhr.open('POST', './register.php?do=addmember', true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { // sucess code } else { if (xhr.status !== 200) { alert('error); } } } xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send(strObj); |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|