0

私のindex.phpには、次のhtml構造があります

<input type="text"  class="url" id="url" name="url" contenteditable="true"  style=" text-align: left; height: 30px; width:422px; " placeholder="Enter URL ..." onfocus='display();' /></input> //Text box
<div id = "myDiv"> // Div which holds response from ajax call
<input type="submit" class="button" onclick="GetSentiment()" id="GetSentiment" value="Get Sentiment" style="display:none;"/> //Button which call function to perform action

そしてajax呼び出し:

function GetSentiment()
        {
  .....
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {                       document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
                    }
                }
                xmlhttp.open("POST","data.php",true); ...

data.php には、次のような結果が含まれています: http://jsfiddle.net/karimkhan/xftr5/

最初は、ボタンはテキスト ボックスのすぐ下にあります。

ボタンをクリックしてアクションを実行すると、data.php ファイルからの応答がテキストボックスのすぐ下に配置されます。

そのため、ボタンが非表示になります。むしろ、data.php のレスポンスの下に配置したいのです。すなわち下myDiv

4

0 に答える 0