For $.ajax, there is another parameter called dataType
. You can specify it to either json
or html
. For your script to work, you need a dataType of html
.
If you do not specify anything, by default it takes text
.
Also I’m not sure whether it is
<script type="application/json"></script>
or
<script type="text/javascript"></script>
By the way, I felt the same when I got the first down vote. But then one of my senior said – “By reviewing your work, your peers are doing you a favor. Please make their life easier.”
solved How use $.ajax download JSON from HTML?