dataString을 서버로 보내는데 문제가 있습니다. Aparently 그것은 폼에서 정확하게 값을 가져 오지 않습니다. 아래 내 jquery와 내 PHP입니다.jquery ajax를 통해 양식 필드를 전송하는 중 오류가 발생했습니다.
$(document).ready(function() {
$("#submitForm").live('click', function() {
updateUserInfo();
});
var birthdate = $("#birthdate");
var sex = $("#sex");
var interestedIn = $("#interestedIn");
var relationshipStatus = $("#relationshipStatus");
var knownLanguages = $("#knownLanguages");
var religiousViews = $("#religiousViews");
var politicalViews = $("#politicalViews");
var aboutMe = $("#aboutMe");
var mobilePhone = $("#mobilePhone");
var neighborhood = $("#neighborhood");
var website = $("#website");
var email = $("#email");
var dataString = birthdate + sex + interestedIn + relationshipStatus + knownLanguages + politicalViews + aboutMe + mobilePhone + neighborhood + website + email;
function updateUserInfo() {
jQuery.ajax({
type: "POST",
dataType: "JSON",
url: "<?=base_url()?>index.php/regUserDash/updateUserInfo",
data: dataString,
json: {userInfoUpdated: true},
success: function(data) {
if(data.userInfoUpdated == true) {
alert("hello");
}
}
});
}
});
내 PHP :
public function updateUserInfo() {
$userid = $this->session->userdata('userid');
$birthdate = $this->input->post("birthdate");
$sex = $this->input->post("sex");
$interestedIn = $this->input->post("interestedIn");
$relationshipStatus = $this->input->post("relationshipStatus");
$languages = $this->input->post("languages");
$religiousViews = $this->input->post("religiousViews");
$politicalViews = $this->input->post("politicalViews");
$aboutMe = $this->input->post("aboutMe");
$mobilePhone = $this->input->post("mobilePhone");
$neighborhood = $this->input->post("neighborhood");
$websites = $this->input->post("websites");
$email = $this->input->post("email");
$this->db->query("INSERT IGNORE INTO user_info (birthdate, sex, interestedIn, relationshipStatus, Languages, religiousViews, politicalViews, aboutMe, mobilePhone, neighborhood, websites, email, userid)
VALUES('{$birthdate}', '{$sex}', {$relationshipStatus}', '{$languages}, {$religiousViews}', '{$politicalViews}', {$aboutMe}', '{$mobilePhone}' {$neighborhood}', '{$websites}', {$email}', '{$userid}')");
echo json_encode(array('userInfoUpdated' => true));
}
늦게 답장을 보내 주셔서 죄송합니다,하지만 여전히 작동하지 않습니다. 내 오류는 다음과 같습니다. http://i50.tinypic.com/2bp750.png. 당신이 눈치 채면 그것은 심지어 json을 지나치지 않습니다. –
콘솔에서 js 오류를 확인하십시오. – mintobit
모든 것이 올바르게 실행 중입니다. 이것은 이상합니다. http://pastebin.com/R7tjfkDx라면 도움이 될만한 PHP가 여기 있습니다. –