[jQuery] ajax.request equivalent in jquery
Hey all...
I am doing a conversion of prototype to jquery and am stuck on a
script... I can't figure out how to define certain fields.
Here's the prototype call:
new Ajax.Request(url,
{
method:'post',
postBody: 'media_id='+media_id,
onSuccess: trigger,
onComplete: function()
{
leftPos = Position.positionedOffset($('doc'))[0];
if (window.pageYOffset)
ScrollTop = window.pageYOffset;
else
ScrollTop = (document.body.parentElement) ?
document.body.parentElement.scrollTop : 0;
$('fade').setStyle({height: $('doc').getHeight()+'px'});
$('popup').setStyle({left: (leftPos+138)+'px'});
$('popup').setStyle({top: (ScrollTop+50)+'px'});
}
});
I've attempted to convert and got this far...
jQuery.ajax({type: "POST",
url: url,
data: 'media_id='+media_id,
success: trigger,
complete: function() {
leftPos = Position.positionedOffset(jQuery('#doc'))
[0];
if (window.pageYOffset)
ScrollTop = window.pageYOffset;
else
ScrollTop = (document.body.parentElement) ?
document.body.parentElement.scrollTop : 0;
jQuery('#fade').setStyle({height: jQuery('#doc').height
()+'px'});
jQuery('#popup').setStyle({left: (leftPos+138)+'px'});
jQuery('#popup').setStyle({top: (ScrollTop+50)+'px'});}
});
To make things worse, there's a check in there to see if you're logged
in and if not calls the following:
new Ajax.Request('/profile/signin?noredirect=1',
{
method:'post',
postBody: Form.serialize($('signin_form_popup')),
onSuccess: callback
});
which I've attempted to convert to :
jQuery.ajax({type:'POST',
url: '/profile/signin?noredirect=1',
postBody: Form.serialize(jQuery
('#signin_form_popup')),
success: callback});
I think it's all working but am not sure...I have no idea what to do
with the "postBody" parameter...what is it's equivalent in jquery.
Any help would be greatly appreciated.
Thanks