Reputation: 3330
I am trying to create a generic way to call ajax requests in my webpage. I've created a nice little extensions method to call a post request asynchronously.
$.tiqPost = function(action,data,callback)
{
alert('Posting...');
$.fancybox.showActivity();
$.ajaxSetup({async:true});
$.post('/portfolios/mod/t:'+action+'/',data,function(response)
{
callback(response);
$.fancybox.hideActivity();
alert('Finished Post.');
});
alert('Posting Set.');
}
However, whenever this request fires, my page freezes indefinitely. In some versions of Chrome, it freezes with no feedback (clicking stops working, I cannot close the tab). It most other browsers though, it shows "Posting" and then stops without ever reaching "Posting Set" or "Finished Post".
So Chrome catches no errors and just freezes. This is very puzzling to me. Anyone have any tips (or even just a different implementation)?
EDIT:
This does not happen for every request. In fact, let me post some cases where it works and some cases where it doesn't. Hold on...
EDIT EDIT:
So in this example
$.tiqPost('newcat',{t:"n"},function(response)
{
if(response)
{
$tabs.tabs('add','#tiq-tab-'+response,"New Category",0);
}
});
I am having no problems. However:
$(this).bind('blur',function(postdata)
{
//blur
if(postdata==null)
postdata = {value:$(this).text()};
$.tiqPost($(this).attr('id').replace('tiq-submit-',''),
postdata,
function (response) {
$(this).text(response);
});
$(this).removeClass('tiq-editable-editstate');
$(this).attr('contentEditable','false');
});
Causes the freeze.
Upvotes: 2
Views: 702
Reputation: 21221
does doing
$.post('/portfolios/mod/t:'+action+'/',data,function(response)
{
callback(response);
alert('Finished Post.');
});
alone, works? if it does, then you may have a problem configuring the function itself
Upvotes: 1