Convert JSON Data to HTML doesn't call for "message button to be pressed" to pass
See original GitHub issueChallenge Convert JSON Data to HTML has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
<script>
$(document).ready(function() {
$("#getMessage").on("click", function() {
$.getJSON("/json/cats.json", function(json) {
var html = "";
// Only change code below this line.
json.forEach(function(val) {
var keys = Object.keys(val);
html += "<div class = 'cat'>";
keys.forEach(function(key) {
html += "<b>" + key + "</b>: " + val[key] + "<br>";
});
html += "</div><br>";
});
// Only change code above this line.
$(".message").html(html);
});
});
});
</script>
<div class="container-fluid">
<div class = "row text-center">
<h2>Cat Photo Finder</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well message">
The message will go here
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>
The student doesn’t have to press the button and see the updated output before the test is passed and therefore doesn’t see what the output would be. Suggest to update instructions to tell the student to click the message button at least and if possible don’t pass them unless they have.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Convert JSON Data to HTML doesn't call for "message button ...
The student doesn't have to press the button and see the updated output before the test is passed and therefore doesn't see what...
Read more >How to send a JSON object using html form data
Get complete form data as array and json stringify it. var formData = JSON.stringify($("#myForm").serializeArray());.
Read more >JavaScript JSON parse() Method - W3Schools
The JSON.parse() method parses a string and returns a JavaScript object. The string has to be written in JSON format. The JSON.parse() method...
Read more >How to Use the Fetch API (Correctly) - CODE Magazine
Navigate into the folder Samples-WebAPI and load that folder in Visual Studio Code or Visual Studio 2019. Open the appsettings.json file and ...
Read more >How to Convert HTML Form Field Values to a JSON Object
The FormData API doesn't directly convert form values to JSON, but we can get there by using the entries method and passing its...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@raisedadead maybe just start with the instruction to click message?
I don’t know if I can put this here but if you make a mistake in the html code that can be copy-pasted into the right position, it still validates the test, although there’s a major mistake in the coding and if you press the button nothing happens. for instance : if you remove <html += “<div class = ‘cat’>”;> the test passes but there’s no output due to the problems created in the html code that is being produced.