【发布时间】:2011-04-03 04:00:53
【问题描述】:
我想创建搜索日志文件历史的搜索页面。由于显示区域的限制,我希望用户在显示搜索结果之前限制日志文件的日期范围。
我已经创建了日期选择器“from”和“to”,它们将为输入提供日期范围。该按钮将是提交此日期范围。
<Form action="/" id="searchDate">
From: <input type="text" name="from" id="datepickerFrom">
To: <input type="text" name="to" id="datepickerTo">
<input type="submit" value="Submit"/>
</Form>
这里是脚本...
<script>
// attach a submit handler to the form
$("#searchDate").submit(function(event) {
// stop form from submitting normally
event.preventDefault();
var eID = $("#userID").val();
// get some values from elements on the page:
var $form = $( this ),
termFrom = $form.find( 'input[name="from"]' ).val(),
termTo = $form.find( 'input[name="to"]' ).val(),
url = $form.attr( 'action' );
// Send the data using post and put the results in a div
$.post("/home/", function(data){
$( "#result" ).load("/search/"); //.html(termFrom+" "+termTo);
}
);
});
</script>
如果我使用 $( "#result" ).html(termFrom+" "+termTo);声明,但 .html 它只接受 html 字符串。我想将日期发布到外部页面以执行查询并将该外部页面加载到搜索框页面的 div 中,所以我使用 .load("/home/search/")。我只想测试加载外部页面而不传递帖子值,但它不起作用。为什么 .load() 在这种情况下不起作用?
提前致谢...
【问题讨论】:
-
首先,它的
form不是Form。 -
改变Form形成结果还是一样...
-
如果您转到
/search或您在浏览器中使用.load调用的任何网址会发生什么?