<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
$(function(){
$('button').click(function(){
$.ajax({
type: 'GET',
url: "http://localhost/cakephp-2.6.3_smarty/sample1.json",
dataType: 'json',
cache: false,
success:function(data){
$('p') .html(data);
}
});
});
});
</script>
<p>Pre-modification</p>
{"data1":, "data2":"}
I'm running with the above code, but the output doesn't change anything.
If dataType: 'json', is set to dataType: 'html', {"data1":, "data2":"} will be printed.
How can I get the json data?
I would appreciate it if you could let me know.
{"data1":, "data2":"}
is incorrect as JSON. If the contents of sample1.json are {"data1":","data2":"}
, it will work.
© 2024 OneMinuteCode. All rights reserved.