I have the following **ajax long polling script**

```
(function poll(){
    $.ajax({ url: "<?php echo URL::to('/internal/v1/checkTxn');  ?>", success: function(data){
        //Update your dashboard gauge
        console.log(data.status);  //Data is getting logged
        if(data.status == 'success'){  //This condition is not being checked
            console.log('suucesful'); //Not coming
        }
    }, dataType: "json", complete: poll, timeout: 1000 });
})();

```

The **backend PHP** code is as follows

```
 if(isset($_POST['status']) && $_POST['status']){
            $data = ['status'=>$_POST['status']];
            $json = json_encode( $data );
           echo $json;
        }

```

**Flow**

1. When I render the page, the ajax script runs and waits for response. When I checked the network tab, ajax was endlessly making requests to the URL specified.
2. I get a form post from an external website to the backend PHP which I need to push to the jquery.

But when a post is happening, nothing is being logged in the console. But if I hard code some values in the **$json** and echo it, its coming up in the console.

I am facing two issues

1. When a post happens on the PHP script, its not coming up in the ajax code.
2. When I hard code (simulated the response posted by the external form post) the **$json** and echo it, its coming up in the console, but the condition for **data.status== 'success'** is not getting checked.

What is wrong in this. Am I missing something?

**UPDATE**

> 
> 
> ```
> I could fix the "condition not being checked" as there was something wrong the json being echoed.
> 
> Now to avoid confusion, the flow for this
> 
> User open the page, 
> 
> > The ajax starts the long polling process to my PHP code, waiting for a
> > response.User enters payment details in a form which is my html,clicks on pay, a pop up appears
> > which renders the banks login page (Payment gateway).After user entering all
> > details in the pop up (banks page), bank sents a server to server call about the status of
> > transaction to my notificationURL
> > ('mydomain.com/internal.v1/checkTxn'). As soon as I get a POST on this
> > URL(I will close the pop up), my ajax polling should get the data posted to my PHP and there by
> > I will show the status of TXN to the user on the same card form he entered his details earlier and
> > the pop window closes. The response here is returned by my PHP code to the ajax.
> The
> > post coming to my PHP code is a server to server post which is posted
> > by a Payment Gateway.
> 
> ```
> 
>