Ajax,Javascript,Python


                    

从位于/script.py的python脚本中,我想在html页面上看到storeNum。</ p>

  def testpost(storeNum):
     storeNum = int(storeNum)+ 1
     返回storeNum
</ code> </ pre>

然后在html页面上,我有了JScript </ p>

  function create_xml_http(){
     if(window.XMLHttpRequest){// IE7 +,Firefox,Chrome,Opera,Safari的代码
         var xmlhttp = new XMLHttpRequest();
     } else {// IE6,IE5的代码
         alert(“此页面不支持Internet Explorer。请在另一个页面中打开\
        浏览器。”)
     }
     返回xmlhttp;
}

函数sendStoreNum(){
     var storeValue = + document.getElementById('strNum')。value;
     如果(storeValue ==''){
         返回;
     }
     var sendStoreNum.onreadystatechange = create_xml_http();
     var url ='home / jholstine / workspace / oreilly / sqltest.py / testpost'
     如果(storeValue> = 1){
         警报(“使其发布”);
         sendStoreNum.open('POST',url,true);
     }其他{
         alert('您输入的是文本而不是数字!');
         sendStoreNum.send();
         storeValue.value ='';
         返回
     }
}
</ code> </ pre>

我似乎无法让这两个说话。 我只想在文本框中输入数字,然后按Enter。 然后将其发送回商店编号加1。有人可以帮助他们进行交谈吗?</ p>
     </ div>

展开原文

原文

From a python script located at /script.py, I want to see storeNum on the html page.

def testpost(storeNum):
    storeNum = int(storeNum) + 1
    return storeNum

Then on the html page I have JScript

function create_xml_http() {
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        var xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
        alert("This page does not support Internet Explorer.  Please open in another\\
       browser.")
    }
    return xmlhttp;
}

function sendStoreNum() {
    var storeValue = +document.getElementById('strNum').value;
    if (storeValue == '') {
        return;
    }
    var sendStoreNum.onreadystatechange = create_xml_http();
    var url = 'home/jholstine/workspace/oreilly/sqltest.py/testpost'
    if (storeValue >= 1) {
        alert('made it to post');
        sendStoreNum.open('POST', url, true);
    } else {
        alert('You have enter a text instead of a number!');
        sendStoreNum.send();
        storeValue.value = '';
        return
    }
}

I can't seem to get these two to talk. I just want to enter the number into a text box and hit enter. Then have it send back the store number plus 1. Can someone please help make these to talk?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问