<script language="javascript" type="text/javascript">
var actNo="";
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
var req = getXMLHTTP();
function getdetails(pay_type) {
var strURL="getwithdrawdetails.php?pay_type="+pay_type;
req.onreadystatechange = statechanged;
req.open("GET", strURL, true);
req.send(null);
}
function statechanged(){
if (req.readyState == 4) {
// only if "OK"
document.getElementById("withdrawdetails").innerHTML = req.responseText;
}
}
</script>
**********************************************
Ajax with success redirection with file upload
**********************************************
$(function () {
$("#testfrm").validate({
rules: {
name: {
required: true
},
address: {
required: true,
maxlength: 100
},
file: {
required: true
}
},
messages: {
name: {
required: "Please select name."
},
address: {
required: "Please enter address.",
maxlength: 'Address length should not be more than 100.'
},
file: {
required: "Please select file."
}
},
submitHandler: function (response) {
var formData = new FormData($('#testfrm')[0]);
$.ajax({
url: set_your_url,
type: 'POST',
data: formData,
dataType: 'json',
contentType: false,
processData: false,
beforeSend: function () {
// Start loading
},
complete: function () {
//Stop loading
},
success: function (response) {
switch (response.status) {
case 1:
showalert(response.msg, 'testfrm', 'alert-danger');
$('form[name="testfrm"]').trigger("reset");
break;
case 0:
showalert(response.msg, 'testfrm', 'alert-success');
window.location = 'redirection location';
break;
default:
break;
}
}
});
}
});
});
Comments
Post a Comment