Yii Framework Forum: javascript function call after process execution - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

javascript function call after process execution Rate Topic: -----

#1 User is offline   raghavAgarwal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 21-March 13
  • Location:Gurgaon

Posted 11 September 2016 - 11:59 PM

I am facing issue regarding javascript. Onclick of button a call a function

function onButtonClickFunction()
{
    ajaxCall();
}

function ajaxCall()
{
    $('.black_overlay').show();

    /* Some Ajax Code */

    $('.black_overlay').hide();
}

So here I am facing the issue is, When I call the ajaxCall function, ideally overlay should be appear, But this will appear and hide at the end of the Ajax response.

There is no error in the console. And when check with the breakpoints then this function sequentially works.

I really didn't come to know, where should be the problem. What should I check for this?

Any help would be appreciated.

Thanks!
0

#2 User is offline   Patrick Jones 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 495
  • Joined: 14-July 12
  • Location:Berlin

Posted 12 September 2016 - 01:49 AM

Your ajax code is likely asynchronous. The request is started but the program continues running before it's finished.

In that case you'd need to hide the overlay upon completion of the request.
Freelance developer for hire - send me a message!
0

#3 User is offline   raghavAgarwal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 57
  • Joined: 21-March 13
  • Location:Gurgaon

Posted 12 September 2016 - 02:31 AM

View PostPatrick Jones, on 12 September 2016 - 01:49 AM, said:

Your ajax code is likely asynchronous. The request is started but the program continues running before it's finished.

In that case you'd need to hide the overlay upon completion of the request.

Thanks for your response.

But the problem is not with the hiding. Problem is with the appearing overlay. I want to appear overlay as the ajaxCall function called, but it appears, after Ajax response.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users