2014-05-06 52 views
0

爲什麼此代碼的工作(只要它拉回到一個空的「CustomerObject」在Chrome控制檯爲什麼查詢只在一個函數中不包含返回數據

var CustomerObject = Parse.Object.extend("CustomerObject"); 
var retrieve = new Parse.Query(CustomerObject); 
retrieve.equalTo("customernumber", $('#searchnumber').val()); 
     retrieve.first({ 
      success: function(retrieveResults) 

     { 

     } 

    }); 
     var cname = retrieve.get("customername"); 
     var cnumber = retrieve.get("customernumber"); 

查看,但該代碼內當用戶點擊搜索按鈕功能不返回任何 「CustomerObject」?

HTML

<input type="text" name="searchnumber" id="searchnumber" value="" placeholder="Customer Number"/> 
    <button type="submit" onclick = "search" >Find</button> 

JS

function search() { 
var CustomerObject = Parse.Object.extend("CustomerObject"); 
var retrieve = new Parse.Query(CustomerObject); 
retrieve.equalTo("customernumber", $('#searchnumber').val()); 
     retrieve.first({ 
      success: function(retrieveResults) 

     { 

     } 

    }); 
     var cname = retrieve.get("customername"); 
     var cnumber = retrieve.get("customernumber"); 

    }; 

回答

0

缺失支架<button type="submit" onclick = "search() " >Find</button>

相關問題