我已经发布了AJAX,但是它被重定向到get请求而不是post请求。发生了什么事?
以下是我的代码:
$.ajax({
type: "post",
url: '<?php bloginfo('template_directory'); ?>/ajax_free_quote_form.php',
data: "url="+url+"&name="+name+"&phone="+phone+"&email="+email+"&kw="+kw+"&x_url="+x_url,
success: function(data){
if (data == '3'){
$("#content .free_seo_quote form #step2").css({display:'none'});
$("#content .free_seo_quote form #step3").css({display:'block'});
$("#content .free_seo_quote form").append("<div style='display:none'><iframe src='<?php bloginfo('template_directory'); ?>/thankyou.html' name='' width='1px' height='1px'> </iframe></div>");
}
else{
$("#content .free_seo_quote form #step2").css({display:'none'});
$("#content .free_seo_quote form #step3").css({display:'block'});
}
}
});
$.ajax({
type: 'post',
url: 'http://www.rankreport.com.au/ajax/add_new_lead',
data: 'lead_company_id=41&lead_business='+url+'&lead_first_name='+name+'&lead_website='+url+'&lead_phone='+phone+'&lead_email='+email+'&lead_package=seo',
success: function(data) {
}
});
答案 0 :(得分:0)
尝试使用xmlhttp对象:
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("results").innerHTML=xmlhttp.responseText;
}
}
var user = document.getElementById("userid").value;
var usernm = document.getElementById("username").value;
if(usernm.split(" ").length==1)
{
var pwd = document.getElementById("password").value;
var ath = document.getElementById("authority").value;
var email = document.getElementById("emailid").value;
var params = "user=" + user + "&usernm=" + usernm + "&pwd=" + pwd + "&ath=" + ath + "&email=" + email;
xmlhttp.open("POST","insertdb.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send(params);