Javascript函数和变量我没有让它工作

时间:2014-02-14 21:35:37

标签: javascript function variables

我正在开发一个jquery移动webapp。 我从一个表单开始,如果它已提交,我想使用多个函数来填充listview。 完成所有功能后,我想刷新列表视图并切换到页面。

<script type="text/javascript">
function getBike(frameNumber){
// Make request and fill result page

soapreq = $.getJSON('json.php?framenummer='+frameNumber, function(data) {
    // Save data to variable for later use.
    bicycleData = data;
    list += '<li data-role="list-divider">'+data.merk+' '+ data.type+'</li>';
    list += '<li>'
        list += '<div class="search_desc">'
            list += '<div class="row">'
                list += '<div class="key">Merk:</div>';
                list += '<div class="value">'+data.merk+'</div>';
            list += '</div>'
            list += '<div class="row">'
                list += '<div class="key">Type:</div>';
                list += '<div class="value">'+data.type+'</div>';
            list += '</div>'
            list += '<div class="row">'
                list += '<div class="key">Framehoogte: </div>';
                list += '<div class="value">'+data.maat+'</div>';
            list += '</div>';
            list += '<div class="row">'
                list += '<div class="key">Versnellingen: </div>';
                list += '<div class="value">'+data.versnellingen+'</div>';
            list += '</div>';
            list += '<div class="row">'
                list += '<div class="key">Modeljaar: </div>';
                list += '<div class="value">'+data.modeljaar+'</div>';
            list += '</div>';
            list += '<div class="row">'
                list += '<div class="key">Adviesprijs: </div>';
                list += '<div class="value">'+data.advprijs+'</div>';
            list += '</div>';
            list += '<div class="row">'
                list += '<div class="key">Status: </div>';
                list += '<div class="value">'+data.status+'</div>';
            list += '</div>';
        list += '</div>';
        list += '<div class="bike_image"><img class="bike_image" src="'+data.image+'" onclick="openPopup('+data.merk+')"></div><li>';
});

// If request succesful
soapreq.complete(function() {
    console.log( 'getWilmarBike request was succesful' );
    succes = 1;
});
// If request failed
soapreq.fail(function() {
  console.log( "getBike request failed" );
  succes = 0;
});
return {"succes":succes, "list": list, "data": bicycleData };
}
</script>

现在我想使用返回值;我希望这样做:

stepOne = new getWilmarBike(frameNumber.value);
console.log(stepOne);

我试过了,但控制台日志是:

Object {succes: "", list: "", data: ""} 

所以我做错了什么。如果有人可以帮我解决这个问题..

0 个答案:

没有答案