Search code examples
phpformscordovasubmitjqtouch

form submit phonegap jqtouch


i have seen similar posts here but i have had no luck solving my problem so I thought I'd ask:

i am using jqtouch framework to submit a form (index.html) to a php file on my webserver (myphpfile.php)...

in my index.html:

<form class="form" method="post" action="http://mydomain.com/myphpfile.php">
//form inputs
<input type="hidden" id="doSubmit" name="doSubmit" value="Submit">
<a href="#" class="submit whiteButton">Submit!</a>
</form>

this works in web browsers (firefox, safari, chrome), see www.newhereinc.com but when it is compiled in xcode with phone gap it doesn't submit the form

I have also added "" and ".*" to Phonegap plist file ExternalHosts Array...with no luck

I have read that I need to do this as a XHR Post request...which i am unfamiliar with?

any help would e greatly appreciated


Solution

  • <form class="myformid" method="post" >
    
    //form inputs
    <input type="hidden" id="doSubmit" name="doSubmit" value="Submit">
    
    <a href="#" class="submit whiteButton">Submit!</a>
    </form>
    
    
    
    
    $('#myformid').submit(function() {
    
    var formdata = $("#myformid").serialize();
    
    $.ajax({
      type: 'POST',
      url: http://mydomain.com/myphpfile.php,
      data: formdata,
      success: success,
      dataType: json,
    });
    })