我通過post方法發送一些值到jquery ajax方法中使用字符串bulider在服務器端編碼的php頁面。但是當我嘗試發送值是說undefined.i dono如何通過cliendid.it是否正確?在jQuery中獲取值undefined形式字符串bulider
protected void btnAdd_Click(object sender, EventArgs e)
{
c.MyQuery("insert into tblHrims_currentOpeningsNew(nvrDesignation,nvrCompany,nvrExperience,nvrLocation,nvrEducation,nvrDepartment,nvrIndustryType,nvrFnalArea,nvrJobDesc,nvrDesiredProfile,nvrContactPerson," +
" nvrContactNumber,nvrEmailId,nvrWantedPositions,nvrAddedBy,dttAddedon) values('" + txtDesg.Text.Trim().Replace("'", "") + "','" + ddlCompany.SelectedItem.Text + "','" + txtExperience.Text + "','" + txtLocation.Text + "','" + txtEducation.Text + "'," +
" '" + txtDept.Text.Trim().Replace("'", "") + "','" + ddlIndustryType.SelectedItem.Text + "','" + ddlFnalArea.SelectedItem.Text + "','" + txtJobDesc.Text.Replace("'", "''") + "','" + txtDesiredProfile.Text.Replace("'", "") + "'," +
" '" + txtContactName.Text.Trim().Replace("'", "") + "','" + txtContactno.Text.Trim().Replace("'", "") + "','" + txtEmailid.Text.Trim().Replace("'", "") + "','" + txtPositionWanted.Text.Trim().Replace("'", "") + "'," +
" '" + txtAddedBy.Text.Trim().Replace("'", "") + "','" + c.GetValue("select getdate()") + "')");
string strID = c.GetValue("select max(intsno) from tblhrims_currentopeningsNew");
lblAlert.Visible = true;
lblAlert.Text = "SucessFully Added";
StringBuilder mystringbuilder = new StringBuilder();
mystringbuilder.Append("$(document).ready(function(){\n");
mystringbuilder.Append(" var ddlCompany = $(\"#<%=this.ddlCompany.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtLocation = $(\"#<%=this.txtLocation.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtDept = $(\"#<%=this.txtDept.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var ddlIndustryType = $(\"#<%=this.ddlIndustryType.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtDesg = $(\"#<%=this.txtDesg.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var ddlFnalArea = $(\"#<%=this.ddlFnalArea.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtExperience = $(\"#<%=this.txtExperience.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtJobDesc = $(\"#<%=this.txtJobDesc.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtEducation = $(\"#<%=this.txtEducation.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtDesiredProfile = $(\"#<%=this.txtDesiredProfile.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtPositionWanted = $(\"#<%=this.txtPositionWanted.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtAddedBy = $(\"#<%=this.txtAddedBy.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtContactName = $(\"#<%=this.txtContactName.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtEmailid = $(\"#<%=this.txtEmailid.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" var txtContactno = $(\"#<%=this.txtContactno.ClientID %>\").attr('value'); \n");
mystringbuilder.Append(" $.ajax({\n");
mystringbuilder.Append(" type: \"POST\",\n");
mystringbuilder.Append(" url: \"http://172.16.126.32/Riyas/marggroup.com/get-current-openings.php\",\n");
mystringbuilder.Append(" data: \"ddlCompany=\" + ddlCompany + \"& txtLocation=\"+ txtLocation+\"& txtDept=\"+ txtDept+\"& ddlIndustryType=\"+ ddlIndustryType+\"& txtDesg=\"+ txtDesg+\"& ddlFnalArea=\" + ddlFnalArea+\"& txtExperience=\"+ txtExperience+\"& txtJobDesc=\"+ txtJobDesc+\"& txtEducation=\"+ txtEducation+\"& txtDesiredProfile=\"+ txtDesiredProfile+\"& txtPositionWanted=\"+ txtPositionWanted+\"& txtAddedBy=\"+ txtAddedBy+\"& txtContactName=\"+ txtContactName+\"& txtEmailid=\"+ txtEmailid+\"& txtContactno=\"+ txtContactno,\n");
mystringbuilder.Append(" success: function(response){\n");
mystringbuilder.Append(" $('div.success').html(response); \n");
mystringbuilder.Append(" }\n");
mystringbuilder.Append(" });\n");
mystringbuilder.Append("});\n");
Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", mystringbuilder.ToString(), true);
}
在什麼行是「未定義」 - 你檢查了瀏覽器的控制檯(F12)?什麼看起來像JavaScript在HTML中? –
看到我將發送這個測試箱的值爲PHP ....所以這些值我越來越未定義... –