Skip to content

Commit

Permalink
json文件加载失败的话,页面输出对应的错误信息
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskey committed Apr 11, 2017
1 parent 8bce95f commit 04748fa
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,19 @@ <h2>EasyResume initiailized error</h2>
</div>

<script type="text/babel">
$.getJSON("resume.json",[],function(data){
console.log('[resume.json read successfully]',data);
var json = data;
ReactDOM.render(<div><Resume json={json}/></div>,document.getElementById('container'));
$.getJSON("resume.json",[])
.done(function(data){
console.log('[done][resume.json read successfully]',data);
var json = data;
ReactDOM.render(<div><Resume json={json}/></div>,document.getElementById('container'));

var name = json.name;
if(name) document.title='EasyResume-'+name;
});
var name = json.name;
if(name) document.title='EasyResume-'+name;
}).fail(function(jqxhr, textStatus, error ){
var err = textStatus + ", " + error;
console.error( "[Request resume.json Failed]: " + err );
$('#defaultMsg').html("加载/解析resume.json文件错误 :"+textStatus+"。请确认json文件存在并且配置格式正确。<br> error :" +error);
});

//一秒后显示默认的提示区域,如果正常初始化,$('#defaultMsg')将不存在,故没有作用
window.setTimeout(function(){
Expand Down

0 comments on commit 04748fa

Please sign in to comment.