如何使用ajax从另一个页面读取html数据

时间:2015-06-10 15:10:00

标签: javascript ajax

这是网址" users / 1 / providers / 1 / check"到包含以下html的页面

<select id="document1" class="form-control">
        <option th:value="0" >Select a document you want to share</option>
        <option th:each="document : ${documents}" th:value="${document.id}" th:text="${document.name}">[name]</option>
</select>

在此网址&#34; / users / 1 / providers / 1 / documents / 1 / consents / new:我想从&#34; users / 1 / providers / 1 / check&#访问html中的数据34;

<select id="provider" name="provider" class="form-control" th:onchange="'javascript:showPIIDoc(this.value);'">
                                                    <option th:value="0" >Select a Service Provider</option>
                                                    <option th:each="provider : ${user.providers}"  name="name"  th:value="${user.id} +','+ ${provider.id}" th:text="${provider.name}" >[name]</option>
                                                </select>

使用ajax我将如何做到这一点。我正在使用spring mvc

function showPIIDoc(doc)
{
    var split = doc.split(",");
    var userId = split[0];
    var providerId = split[1];
    $.ajax({ 
        url: '/users/'+ userId +'/providers/' + providerId + '/check',
        success: function(html){
            //Create jQuery object from the response HTML.
            var $response=$(data);

            //Query the jQuery object for the values
            var oneval = $response.filter('#document1').text();
            alert(oneval);
        }
    });
    });

}

请指导我

0 个答案:

没有答案