2014-06-04 09:44


  • cordova
  • php
  • html
  • jquery

Currently I'm working on a project which has a form that connects to an external database. First I made an example, just to test if it worked. This worked fine.

But when I tried implementing it, the form doesn't empty anymore, while the example does empty the fields. My code is exactly the same, so I don't understand what's wrong. The only difference is that one file is within a jquery-mobile/phonegap folder, and the other on my htdocs.

(It does work, the only thing that it doesn't do is empty the form input fields after submitting, which is confusing for the user)

Here's my code:


    <link rel="stylesheet" href="themes/" />
    <link rel="stylesheet" href="" />
    <script src=""></script>
    <script src=""></script>
    <script type="text/javascript" src="js/demo.js"></script>
        function onBodyLoad() {     

<body onload="onBodyLoad()">

<div data-role="page" id="page7" class="pagina">
                <div data-role="header">
                </div><!-- /header -->

            <div data-role="content" id="content">
                <div id="weekoverzicht">
                <form id="overzicht" method="post" onsubmit="return infoOverzicht()">
                    <label for="fruit">
                        <input type="text" id="fruit" name="fruit">

                    <label for="groente">
                        <input type="text" id="groente" name="groente">

                    <label for="beweging">
                        <input type="text" id="beweging" name="beweging">

                    <label for="duur">
                        <input type="text" id="duur" name="duur">

                    <input type="submit" value="Save">
                <div data-role="content">
                    <a data-role="button" data-transition="fade" href="#" id="button"> Data ophalen </a>
                        <table data-role="table" data-mode="columntoggle" class="ui-responsive" id="myTable">
                          <th data-priority="1">Fruit</th>
                              <th data-priority="1">Groente</th>
                              <th data-priority="1">Beweging</th>                             
                          <tbody data-role='listview' data-theme='c' id='mylist'></tbody>

                    <p id="showData"></p>
            <div data-role="footer" style="text-align:center;" data-position="fixed">
                <div data-role="navbar">
                        <li><a href="index.html" data-icon="home">Home</a></li>
                        <li><a href="test.html" data-icon="plus">Test</a></li>
                        <li><a href="doel.html" data-icon="star">Doel</a></li>
                        <li><a href="score.html" data-icon="check">Score</a></li>
            </div><!-- /footer -->

Js file:

    var url = "";
    console.log("first page initialized");  

        type: "POST",
        url: url + "complex.php",
        cache: "false",
        dataType: "json",
        success: function(phpData){ 
        console.log("Complex: " + phpData);

            $("#showData2").append("<b>" + phpData.comments[0].sport + "</b>");

            $.each(phpData.comments, function(index, berichtje){
                    "<tr>" + 
                    "<td>" + berichtje.fruit + "</td>" +
                    "<td>" + berichtje.groente + "</td>" +
                    "<td>" + berichtje.beweging + "</td>" + "</tr>"


         error: errorHandling                   

function infoOverzicht(){
                var data = $('form#overzicht').serialize();
                    url: "",
                    type: 'POST',
                    data: data,
                    beforeSend: function() {
                        success: function(data, textStatus, xhr) {
                        error: function(xhr, textStatus, errorThrown) {
                return false;

function errorHandling(){

    console.log('er gaat iets fout');


I tried solutions like this one, but to no avail: Clear form after submission with jQuery

Does anyone know what I'm doing wrong? It's probably some stupid little thing, but I can't find it, haha.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享