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");
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");
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
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");
/* 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
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,