2017-01-17 5 views
0

私はまだ数日間それを解決しようとしています。私は原料の多くを試してみたが、誰も働いていない:Jクエリajax、未定義の値を取得

は、ここでそれは未定義と言うコード

$(document).ready(function(){ 
    $("#buttonclick").click(function() { 
     var myval = { 
      FirstName: $('#TxtFirstNamePhysician').val(), 
      LastName: $('#TxtLastNamePhysician').val(), 
      EmailId: $('#TxtEmailIdPhysician').val(), 
      Password: $('#TxtPasswordPhysician').val(), 
      PhoneNumber: $('#TxtPhoneNoPhysician').val() 
     }; 

     $.ajax({ 
      url: "http://localhost:49956/Physician_Registration/Physician_Reg", 
      type: 'POST', 
      data: myval, 
      dataType: "text", 
      success: function (data) { 
       alert(data.responseText); 
      }, 
      error: function (xhr, ajaxOptions, thrownError) { 
       alert(xhr.status); 
       alert(thrownError); 
      } 
     }); 
    }); 
}); 

です。

This Is what is the error i am getting

+1

私はあなたがそれを言うので、あなたのAJAX呼び出しが成功したと推論(アラート意味?)未定義「と言っ」、およびエラーコールバックは2回に警告します。したがって、定義されていない場合、成功コールバックのデータオブジェクトにはresponseTextという属性がありません。 – Dacklf

+0

正確に定義されていないものは何ですか?いつ? –

+0

それは、のような姓を示す:未定義、姓:未定義、EMAILIDを:それは、ID buttonclick – Abhi

答えて

0

正しいコンテンツタイプを渡すことで、試してみてください。 作業していない場合は、myvalオブジェクトをjsonに変換してください。コンテンツタイプをapplication/jsonとして渡します。

+0

あなたは私のコードをお願いできますか? – Abhi

+0

$( "#のbuttonclick")をクリックします(関数(){ するvar myval = { '姓':$( '#のTxtFirstNamePhysician')のval() }; $アヤックス({ URL:。。 " http:// localhostを:49956/Physician_Registration/Physician_Reg」、 タイプ: 'POST'、 データ:myval、 データ型: "テキスト"、 成功:機能(データ){ 警告(data.responseText);} 、 エラー:function(xhr、ajaxOptions、thrownError){ アラート(xhr.status); alert(thrownError); } }); }); – Pavvy

+0

@AbhiはContentTypeをを含めるのを忘れて:「アプリケーション/ jsonの」 – Pavvy

0

私はそれが適切にマークアップされていないあなたのhtmlによるだと信じています。

私が働いてサンプルを作成し、以下のjsfiddleに行きました。

<body> 
<form> 
<label for="first-name">First Name</label> 
<input name="first-name" id="TxtFirstNamePhysician" /><br> 
<label for="last-name">Last Name</label> 
<input name="last-name" id="TxtLastNamePhysician" /><br> 
<label for="email">Email</label> 
<input name="email" id="TxtEmailIdPhysician" /><br> 
<label for="password">Password</label> 
<input type="password" name="password" id="TxtPasswordPhysician" /><br> 
<label for="phone-number">Phone Number</label> 
<input name="phone-number" id="TxtPhoneNoPhysician" /><br> 
<input type="button" value="submit" id="buttonclick" /> 
</form> 
<div class="output"> 
</div> 
</body> 

Working Sample in JSFiddle

+0

動作していない、それを何度もチェック?確認してくださいあなたはJSFiddleサンプルを試しましたか?私はそれが正常に動作していることを確認しました。 – Abhi

+0

が動作していない –

+0

はいJSFiddleは動作していますが、私の側では正規表現とフィールドの検証が必要です – Abhi