Edit this code so that so that testing display for succefull respone be Jan 4 and also to display unsucceful response with a given username as expected...... function responseReceivedHandler(data) {/* Successful request:{"success": true,"messages": [{ "date": "...", ... },...]}Unsuccessful request:{"success": false,"error": "..."} *//* Your solution goes here */function responseReceivedHandler(data) {if (data.success) {// Display the date of the first message if the request was successfulconsole.log(data.messages[0].date);} else {// Display the error message if the request was unsuccessfulconsole.log(data.error);}}$.get("https://wp.zybooks.com/messages.php", { username: "Kelly22" }, responseReceivedHandler, "json");}$.get("https://wp.zybooks.com/messages.php", { username: "Kelly22" }, responseReceivedHandler, "json");

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question
Edit this code so that so that testing display for succefull respone be Jan 4 and also to display unsucceful response with a given username as expected...... function responseReceivedHandler(data) {
/* Successful request:
{
"success": true,
"messages": [
{ "date": "...", ... },
...
]
}

Unsuccessful request:
{
"success": false,
"error": "..."
} */

/* Your solution goes here */
function responseReceivedHandler(data) {
if (data.success) {
// Display the date of the first message if the request was successful
console.log(data.messages[0].date);
} else {
// Display the error message if the request was unsuccessful
console.log(data.error);
}
}

$.get("https://wp.zybooks.com/messages.php", { username: "Kelly22" }, responseReceivedHandler, "json");

}

$.get("https://wp.zybooks.com/messages.php", { username: "Kelly22" }, responseReceivedHandler, "json");
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,