开发者

ASP.NET MVC 3 Jquery Ajax post not receiving response until server side async function is completed

开发者 https://www.devze.com 2023-03-15 04:02 出处:网络
I\'m posting a form to an MVC action using jquery Ajax. Server side, I call a send mail async function. While debugging, I can see execution continue all the way through the return statement from the

I'm posting a form to an MVC action using jquery Ajax. Server side, I call a send mail async function. While debugging, I can see execution continue all the way through the return statement from the action. Even though th开发者_如何学Goe return statement is reached, the ajax success callback doesn't get called until the async mail function finishes. I observe in Firebug that the POST is still waiting on a response. Why does the response get blocked until the async call finishes? Any way to fix it?

I've tested with both the Visual Studio development web server and localhost IIS 7.5 (windows 7). I have not tested on a windows server box.

I've scoured the web and stack overflow and have not found an answer. The closest thing I found mentioned visual studio web server not being as "threaded" as local IIS, but since I've tested on both, it has to be something else.

Thanks! Philip


that is because the response of your ajax post wait until your ajax call of send mail is finished so you may make calling send mail in another thread or call it using jquery if possible

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号