WCB.PHP - Convert RESPONSE JSON to JAVASCRIPT object?

Hey Friends, after a FORM POST to WCB.PHP, would you know of a method to convert, what appears to be a JSON response into a JAVASCRIPT object? Is this possible?

It’s in the sample on the knowledge base. Aren’t you using the jquery in the sample form that handles posting to the PBX and the json response?

But the simple answer is the $.parseJSON() function

Hey Tom, I’m not, no. I’m using a very simple form that only takes in the phone number and sets a static id which I append to the POST. It works great, and I do receive what I assume is a JSON response from the PBX - “{“Response”:“Success”,“Message”:“Originate successfully queued”}” so I’m looking for a way to extract the response and assume I can do that with $.parseJSON() function, then write in some PHP to pop up a message. Might be easy for you, but we are all at different levels of understanding and learning. Thanks for your response!

Then I would suggest you use the existing example to help you figure this out. It’s why it is there. Actually, how are you posting this to the server? Are you doing it with a form action (<form action="http://domain.com/wcp.php">) or something like that? Are you submitting the form using ajax in javascript/jquery? That’s very import because I gave you how to deal with the json response in javascript/jquery using ajax. If you’re doing a direct post then you need to deal with the response a different way.

So how are you sending the information to the PBX, which method?

Tom, I’m just posting it directly:

Where are you seeing the response? In the web browser as output when it hits the form location?

I do. The response stays in the same pop-up window I had designed and put together for accepting the phone input. I hit the Call button, it established the call, when I hang up the JSON appears, in the same window.

How you are handling the form is sending them to the PBX and that response you see is the output at the PBX. You need a better method of submitting the data and handling the response. This is why the example form uses ajax to submit the form to a remote location, collect the output from the remote location and process it locally.

Doing it how you are now is going to be problematic and cumbersome in handling the response since your final destination is the PBX itself. It would require you to change how the PBX responds with the data and instead of returning it in json it display HTML based responses.

I hear you. But working with the form on the pbx means I have to find a way to submit the id value from the local form the server. Is this what you are suggesting?

I’m going to say what I have said numerous times in these various threads. Use the example. It has the javascript/ajax all laid out to take the data from the form and submit it to the remote location, get the json response and parse said response. It even creates the default popup based on the response. It has all the pieces to place the form on a remote location to submit to the PBX. You just need to adjust it accordingly.

Tom, I have tried that, but I do get a CORS error. The server isn’t accepting the data. Did you suggest at one time wrapping the DIV FRAME element in a FORM?

#frame { background-image: url('/admin/modules/webcallback/assets/images/c2c-1.png'); background-repeat: no-repeat; background-size: 200px; height: 65px; cursor: pointer; cursor: hand; } #webcallbackinput { position: relative; left: 66px; top: 30px; width: 125px; }
Powered by: www.schmoozecom.com

Show this cors error.

Perfect, back to the drawing board. I understand this in principal, let me look research this a see if I find a solution. Thanks for your response, Tom, appreciate it!