Lengkap

Clean jquery post response

I need addition to the below jQuery response that will cleanly clear sent post data and clear input values so that additional request can be made cleanly.

In addition I require the code required to trigger both a successful and failed response to the form post request from the /[login to view URL] file.

Here is the form to work with:

<form id="trans-form">

<select name="make" id="make" required >

<option value="" class="first_option" selected="selected" disabled>Select Asset</option>

<option value="1">car</option>

<option value="2">truck</option>

</select>

<input type="text" name="model" placeholder="Model" value="" readonly />

<input type="number" name="amount" placeholder="Transfer Amount" required />

<input type="text" name="trans-address" id="trans-address" placeholder="address" required />

<input type="submit" name="trans_sub" value="SUBMIT" />

<div id="fal" class="hid-fal">There has been an error. Please re-check your input and try again.</div>

<div id="suc" class="hid-suc">Please check your email to authorise request.</div>

<div id="proc" class="hid-proc">Processing......</div>

</form>

<script type="text/javascript">

jQuery(document).ready(function() {

jQuery('#make').change(function() {

var balance = jQuery('#make').val();

switch(balance)

{

case '1':

jQuery('[name=model]').val('ford');

break;

case '2':

jQuery('[name=model]').val('nissan');

break;

default:

jQuery('[name=model]').val('all');

}

});

jQuery('form#trans-form').on('submit', function(e) {

jQuery('#fal').hide();

jQuery('#suc').hide();

jQuery('#proc').show();

[login to view URL]('/[login to view URL]', jQuery(this).serialize(), function (data) {

// 'data' contains the response from the request

jQuery('#proc').hide();

jQuery('#fal').hide();

jQuery('#suc').show();

// need function here that cleanly clears form inputs and clears all cached information from post request/response

}).error(function() {

// This is executed when the call failed.

jQuery('#proc').hide();

jQuery('#suc').hide();

jQuery('#fal').show();

// need function here that cleanly clears form inputs and clears all cached information from failed post request/response

});

[login to view URL]();

});

});

</script>

Kemahiran: AJAX, Javascript, jQuery / Prototaip, PHP

Lihat lagi: $.post jquery, jquery post json data, javascript ajax post, $.post javascript, jquery ajax post json, jquery post form data, jquery ajax data, jquery ajax post form, http post response redirect html sample, jquery post alert, clean style post, php xml post response, jquery post ajaxform, jquery post selected select box, jquery post ajax zendframework, jquery post selectbox, jquery post xml save, jquery post mysql, php parse post response, post response fedex php

Tentang Majikan:
( 39 ulasan ) Abu Dhabi, United Arab Emirates

ID Projek: #15651382

Dianugerahkan kepada:

baselIssmail

I'd be more than happy to Finish your project effeciently. I noticed that you're from UAE, so we can speak Arabic if it's better for you. Relevant Skills and Experience I have knowledge in all of the required skills. Lagi

$15 USD dalam sehari
(1 Ulasan)
0.4

4 pekerja bebas membida secara purata $21 untuk pekerjaan ini

$25 USD dalam sehari
(37 Ulasan)
4.6
$25 USD dalam sehari
(1 Ulasan)
3.0
dominx99

A proposal has not yet been provided

$20 USD dalam sehari
(1 Ulasan)
0.7