表单提交与geocomplete jquery地理编码不POST纬度&经度 [英] Form submit with geocomplete jquery geocoding doesn't POST latitude & longitude
本文介绍了表单提交与geocomplete jquery地理编码不POST纬度&经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 http://ubilabs.github.com/geocomplete/ 制作表单提交纬度&经度。如果我只是做下面的触发器,它会起作用并填充lat& lng领域。但是,当我添加提交jQuery代码时,它会提交空白字段。我知道它的一些时间的事情,因为我可以看到字段填满,但不是通过POST发送。但我无法弄清楚,有什么建议吗?
I am using http://ubilabs.github.com/geocomplete/ to have a form submit latitude & longitude. If I just do the trigger below it works and fills up lat & lng fields. However, when I add the submit jquery code, it submits blank fields. I know its some timing thing since I can see the fields fill up but not sent via POST. But I can't figure it out, any suggestions?
<script>
$(document).ready(function(){
// Area for any jQuery
$("#geocomplete").geocomplete({
details: "form",
types: ["geocode", "establishment"]
});
$("#geoform").submit(function() {
$("#geocomplete").trigger("geocode");
alert('Handler for .submit() called.');
return true;
});
});
</script>
<form id="geoform" method=post action="/foo.php">
<input id="geocomplete" type="text" placeholder="Type in an address" value="Empire State Bldg" />
<!--<input id="find" type="button" value="find" />-->
<input type="submit" value="Go" />
<fieldset>
<input name="lat" type="text" value="">
<input name="lng" type="text" value="">
<input name="query" type="hidden" value="true">
</fieldset>
</form>
推荐答案
延迟。
I removed the trigger from the submit function and I added a delay.
<script>
$(document).ready(function(){
// Area for any jQuery
$("#geocomplete").geocomplete({
details: "form",
types: ["geocode", "establishment"]
});
$("#submit-button").click(function() {
$("#geocomplete").trigger("geocode");
setTimeout("$('#geoform').submit();",500);
});
});
</script>
<form id="geoform" method=post action="/foo.php">
<input id="geocomplete" type="text" placeholder="Type in an address" value="Empire State Bldg" />
<!--<input id="find" type="button" value="find" />-->
<input id="#submit-button" type="button" value="Go" />
<fieldset>
<input name="lat" type="text" value="">
<input name="lng" type="text" value="">
<input name="query" type="hidden" value="true">
</fieldset>
</form>
这篇关于表单提交与geocomplete jquery地理编码不POST纬度&经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文