jquery .submit(); [英] jquery .submit();

查看:130
本文介绍了jquery .submit();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为Instamapper正在关闭,我正在做这个项目,我试图去月球计算我走了多少公里,我试图让我的web应用程序,我可以使用,而不是。除了我想每5秒自动提交一次数据,我就得到了一切工作。我试图使用.submit(),但它不工作。

编辑:
submit()函数不工作,这是控制台发生的错误:


未捕获的TypeError:对象#的属性'submit'是
不是函数

以下是代码:

 <!doctype html> 
< html>
< head>
< meta charset =utf-8>
< title>无标题文档< / title>
< script src =http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.jstype =text / javascript>< / script>
< script type =text / javascript>
$(document).ready(function(){
setTimeout(function(){
$('form#target')。submit();
},5000) ;
});
< / script>
<?php
if(isset($ _ POST ['submit'])){
echo'works';
}
$ device ='vPhone';
$ date = new DateTime();
$ timest = $ date-> getTimestamp();
?>
< / head>

< body>
< form action =method =postid =target>
< input type =textvalue =<?= $ timest?> name =timestamp/>
< input type =textvalue =<?= $ device?> name =device/>
< input type =submitname =submitid =submit/>
< / form>
< script>
var x = document.getElementById(target);
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
} else {x.innerHTML =此浏览器不支持地理定位。;}
function showPosition(position)
{
x.innerHTML + =< input type ='text'name ='lat'value ='+ position.coords.latitude +
'disable>< br>< input type ='text'name ='lat'value =' + position.coords.longitude +'disable>; }
< / script>
< / body>
< / html>


解决方案

name =submit id =submit这是导致问题的地方。改成别的东西 - 任何东西,真的,我用 name =notsubmitid =notsubmit - 然后表单自动提交。



资料来源: http://api.jquery.com/submit /#comment-106178333



显然,这些属性以某种方式覆盖了jQuery提交功能,因此无法访问它。


Since Instamapper is closing down and I am doing this project where I am trying to get to the Moon counting how much km I have walked I tried to make my web app, which I could use instead. I got everything working except I wanted to automatically submit my form with data every 5 sec. I tried to use .submit() but it isn't working.

EDIT: The submit() function is not working, here is the error from the console:

Uncaught TypeError: Property 'submit' of object # is not a function

Here is the code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"     type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    setTimeout(function(){
        $('form#target').submit();
    }, 5000);
    });
    </script>
<?php
if(isset($_POST['submit'])) {
    echo 'works';
}
$device = 'vPhone';
$date = new DateTime();
$timest = $date->getTimestamp();
?>
</head>

<body>
<form action="" method="post" id="target">
<input type="text" value="<?=$timest?>" name="timestamp" />
<input type="text" value="<?=$device?>" name="device" />
<input type="submit" name="submit" id="submit" />
</form>
<script>
var x=document.getElementById("target");
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition);
    } else {x.innerHTML="Geolocation is not supported by this browser.";}
  function showPosition(position)
    {
      x.innerHTML += "<input type='text' name='lat' value='" + position.coords.latitude + 
  "' disable><br> <input type='text' name='lat' value='" + position.coords.longitude + "'     disable> "; }
</script>
</body>
</html>

解决方案

It's name="submit" id="submit" that's causing the problem here. Change that to something else - anything, really, I used name="notsubmit" id="notsubmit" - and your form gets auto-submitted.

Source: http://api.jquery.com/submit/#comment-106178333

Apparantly these attributes somehow override the jQuery submit function so that it is no longer accessible.

这篇关于jquery .submit();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆