input src data from json

ぐ巨炮叔叔 提交于 2019-12-13 11:07:36

问题


I got a very similar question here: jQuery progressbar with ajax request to json

Can you help me here with a solution?

I try to get the path out of a *.json file and use it for an "input image field" with jquery.

HTML

<input id="pic_1" type="image" src="<!-- what to do here? -->" /> 

JS

$(function() {
    $.ajax({ dataType:"json",
        url: test.json, 
        success: <!-- what to do here? -->,
    });
});

test.json

{ "pic_1":"img/test.png" }

would be glad for similar solution, due to jQuery progressbar with ajax request to json !

Thank you


回答1:


Why don't you use $.getJSON() http://api.jquery.com/jquery.getjson/



来源:https://stackoverflow.com/questions/28397998/input-src-data-from-json

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!