Ajax Javascript Help .. Multiple Values Array 2

What I’m trying to do is post an array of messages asynchronously using this code. I spent over an hour trying to make it only post the four items in the array, but it keeps posting gibberish in addition to the 4 items. Also, it doesn’t redirect when done.

var a = document.body.innerHTML;
formx = a.match(/name=”post_form_id” value=”([\d\w]+)”/)[1];
dts = a.match(/name=”fb_dtsg” value=”([^”]+)”/)[1];
composerid = a.match(/name=”xhpc_composerid” value=”([^”]+)”/)[1];
var msg = [‘my first update’,
‘posting again’,
‘and again’,
‘done’ ];

target = a.match(/name=”targetid” value=”([^”]+)”/)[1];
for (var i in msg) {
pst = “post_form_id=” + formx + “&fb_dtsg=” + dts + “&xhpc_composerid=” + composerid + “&xhpc_targetid=” + target+ “&xhpc_context=home&xhpc_fbx=1&xhpc_message_text=” + encodeURIComponent(msg[i]) + “&xhpc_message=” + encodeURIComponent(msg[i]) + “&UIPrivacyWidget[0]=40&privacy_data[value]=40&privacy_data[friends]=0&privacy_data[list_anon]=0&privacy_data[list_x_anon]=0&=Share&nctr[_mod]=pagelet_composer&lsd&post_form_id_source=AsyncRequest”;

with(newx = new XMLHttpRequest()) open(“POST”, “/ajax/updatestatus.php?__a=1”), setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”) , send(pst);

}

redirect(‘http://apple.com’);

Leave a Reply

Your email address will not be published. Required fields are marked *