ここで私のjqueryスクリプトですが、Ajaxはいつも失敗し、なぜ私は本当に理解できません。ここ は呼び出しです:Ajaxコールは常に失敗します
<script>
function myFunction()
{
var time = document.getElementById('yearsemployed').value + "years";
var baseurlstring = "http://www.quickinsure.co.za/LeadService/Service.asmx/SubmitLatestLoanLead?";
var paramfirstname = document.getElementById('firstname').value;
var paramlastname = document.getElementById('lastname').value;
var paramemailaddress = document.getElementById('emailaddress').value;
var paramcellnumber = document.getElementById('cellnumber').value;
var paramidnumber = document.getElementById('idnumber').value;
var paramnetsalary = document.getElementById('netsalary').value;
var paramgrosssalary = document.getElementById('grosssalary').value;
var paramloanammount = document.getElementById('loanammount').value;
var paramdebtreview = "FALSE";
if(document.getElementById('debtreview').checked == true)
{
paramdebtreview = "TRUE";
}
var e = document.getElementById("bank");
var parambank = e.options[e.selectedIndex].value;
var params = {
UserId:100405,
Firstname:paramfirstname,
Surname:paramlastname,
Email:paramemailaddress,
CellNo:paramcellnumber,
WorkNo:paramcellnumber,
IdNo:paramidnumber,
NetSalary:paramnetsalary,
GrossSalary:paramgrosssalary,
LoanAmount:paramloanammount,
EmploymentTime:time,
UnderDebtReview:paramdebtreview,
Bank:parambank,
SubId:"affcoza_1829_397",
TestMode:"TRUE"
};
str = jQuery.param(params);
var callbackurl = baseurlstring + str;
getloanapplicationcallback(callbackurl);
}
function successCallBack(returnData){
window.location = 'http://www.lowcreditloans.co.za/thank-you-for-submitting/';
}
function errorCallBack(){
window.location = 'http://www.lowcreditloans.co.za/error-processing-request/';
}
function getloanapplicationcallback(callbackurl)
{
// this will generate another thread to run in another function
jQuery.ajax({
url: callbackurl,
type: 'get',
success: successCallBack,
error: errorCallBack
});
}
</script>
そして、ここでは、PHPです:
<form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
<div id="et_contact_left">
<h3 style="padding-bottom:10px">Personal Details:</h3>
<p class="clearfix">
<label for="title">First Name:</label>
<input type="text" required="true" id="firstname" value="" tabindex="1" name="firstname" class="input"/>
</p>
<p class="clearfix">
<label for="title">Last Name:</label>
<input type="text" required="true" id="lastname" value="" tabindex="2" name="lastname" class="input"/>
</p>
<p class="clearfix">
<label for="title">Email:</label>
<input type="text" required="true" id="emailaddress" value="" tabindex="3" name="emailaddress" class="input"/>
</p>
<p class="clearfix">
<label for="title">Cell Number:</label>
<input type="text" required="true" id="cellnumber" value="" tabindex="4" name="cellnumber" class="input"/>
</p>
<p class="clearfix">
<label for="title">Id Number:</label>
<input type="text" required="true" id="idnumber" value="" tabindex="5" name="idnumber" class="input"/>
</p>
<p class="clearfix">
<label for="title">Years Employed:</label>
<input type="text" required="true" id="yearsemployed" value="0" tabindex="6" name="yearsemployed" class="input"/>
<label for="title">Months Employed:</label>
<input type="text" required="true" id="monthsemployed" value="0" tabindex="7" name="monthsemployed" class="input"/>
</p>
<h3>Employment Details:</h3>
<p class="clearfix">
<label for="title">Monthly Gross Salary:</label>
<input type="text" required="true" id="grosssalary" value="" tabindex="8" name="grosssalary" class="input"/>
</p>
<p class="clearfix">
<label for="title">Monthly Net Salary:</label>
<input type="text" required="true" id="netsalary" value="" tabindex="9" name="netsalary" class="input"/>
</p>
<p class="clearfix">
<label for="title">Loan Ammount:</label>
<input type="text" required="true" id="loanammount" value="" tabindex="10" name="loanammount" class="input"/>
</p>
<p class="clearfix">
<label for="title">Total Monthly Expneses:</label>
<input type="text" required="true" id="grosssalary" value="" tabindex="11" name="grosssalary" class="input"/>
</p>
<p class="clearfix">
<label for="title">Bank:</label>
<select name="bank" id="bank" tabindex="6">
<option value="0">First National Bank</option>
<option value="1">ABSA Bank</option>
<option value="2">Nedbank</option>
<option value="3">Standerd Bank</option>
<option value="4">Capitec Bank</option>
<option value="5">Bidvest Bank</option>
<option value="6">RMB</option>
<option value="7">Investec Bank</option>
<option value="8" selected="selected">Other</option>
</select>
</p>
<p class="clearfix">
<label for="title">Paydate:</label>
<input type="text" required="true" id="grosssalary" value="25" tabindex="12" name="grosssalary" class="input"/>
</p>
<p class="clearfix">
<label for="title">Are you under debt review?</label>
<input type="checkbox" id="debtreview" name="debtreview" value="" />
</p>
<p class="clearfix">
<label for="title">Preform Credit Check with Id-Number?</label>
<input type="checkbox" id="creditcheck" name="creditcheck" checked="checked" />
</p>
<p class="clearfix">
<label for="title">I Accept the Terms and Conditions</label>
<input type="checkbox" id="termsandconditions" name="termsandconditions" checked="checked" />
</p>
</div> <!-- et_contact_left -->
<input type="submit" value="Submit Application" tabindex="40" id="submit" name="submit" class="et_contact_submit" onclick=" myFunction()" />
</form>
OPにはURLからの回答が含まれますか? – guradio
URL自体ではなく、ajax呼び出しの別のパラメータでデータを渡すことをお勧めします。 –
あなたは何を得ているのですか?レスポンスは何ですか? – Toxicable