0
我使用.post()
來查詢python函數中設備的狀態。當它是done
時,它應該返回python函數的返回值。我的Python文件的如何從python回覆並在瀏覽器中顯示它?
$.post('/request', {inputText: fbNum,key_pressed: fbType.toString()}).done(function (reply) {
if (reply ^= "count") {
$('#status_table tr #'+eachStatus).empty().append(the-reply-value-here);
} });
部分:
elif "C?" in response[0]:
status="Count= %sH"%response[0].strip()[-2:]
return status
我怎麼能獲取和顯示狀態? 我在jquery中使用.get
嗎?但我不確定格式。它是
$.get("/request", reply).done(function(data){
$('#status_table tr #'+eachStatus).empty().append(the-reply-value-here);});
?? ??我的回覆是Count = FF
。我想要顯示的只是FF
。我應該怎麼做?
感謝您的答覆。 +1 :)照顧解釋'(/^Count \ s * = /。test(reply))'是什麼意思?那麼'reply.replace()'部分呢? – yvonnezoe 2013-05-07 03:32:03
'/^Count \ s * = /。test'是一個正則表達式,用於測試回覆是否以'Count ='開頭,然後是[替換](https://developer.mozilla.org/en/docs/ JavaScript/Reference/Global_Objects/String/replace)函數用於替換「Count =」,您可以將空字符串替換爲「FF」,如我看到的值 – 2013-05-07 03:35:33
。在那裏我可以閱讀更多關於這個/ \ * *。句法? :這對我來說有點困惑。所以'/ .test'只是一個隨機的名字? – yvonnezoe 2013-05-07 03:39:40