전달하는 방법을 매개변수입니다 달러 의 아약스 게시물로의?

나는 그 명시된 대로 자습서는 https://partner. 아래 코드는 url 에 몇 가지 이유로 않는 데이터가 덧붙여집니다 매개 변수로 사용하는 url 에 직접 신앙이니라 나는 그녀들을 field1 hello&quot. ',' /? = &quot 작동하잖아.

$.ajax({
        url: 'superman',
        type: 'POST',
        data: { field1: "hello", field2 : "hello2"} ,
        contentType: 'application/json; charset=utf-8',
        success: function (response) {
            alert(response.status);
        },
        error: function () {
            alert("error");
        }
    }); 
질문에 대한 의견 (1)
해결책

꼭 이래야겠어요 추천합니까 활용할 수 있습니다. '$ 스포스트' 또는 '$ 이제' 간단한 경우에 대한 구문을 포함한다.

$.post('superman', { field1: "hello", field2 : "hello2"}, 
    function(returnedData){
         console.log(returnedData);
});

If you need to catch 실패할 경우, 그냥 이렇게:

$.post('superman', { field1: "hello", field2 : "hello2"}, 
    function(returnedData){
         console.log(returnedData);
}).fail(function(){
      console.log("error");
});

또한 항상 전송하십시오 JSON 문자열이어야 [$ 이제이슨] [3] 또는 $ 스포스트 함께 사용할 수 있습니다 한 번 더 매개변수입니다 끝으로.

$.post('superman', { field1: "hello", field2 : "hello2"}, 
     function(returnedData){
        console.log(returnedData);
}, 'json');

[3]: http://api.jquery.com/jQuery.getJSON/ # 우를다타콜백

해설 (3)

Get 메서드를 사용하여 시도하시겠습니까

var request = $.ajax({
    url: 'url',
    type: 'GET',
    data: { field1: "hello", field2 : "hello2"} ,
    contentType: 'application/json; charset=utf-8'
});

request.done(function(data) {
      // your success code here
});

request.fail(function(jqXHR, textStatus) {
      // your failure code here
});

매개변수입니다 게시물로의 URL 에서 볼 수 있는 방법입니다.

편집: &gt. 사용 중단 Notice: 자크 스피리수세스 () 는 자크 스트리에로 () 및 &gt. jquery 3.0gb 자크 스피리콤프레티 콜백 () 가 있다. 사용할 수 있습니다. &gt. 자크 스피리돈이 (), 자크 스트리프일 () 및 자크 스피리올와이스 () 를 사용할 수 있습니다.

해설 (0)

[이케리지아이아스] (http://api.jquery.com/jquery.ajax/) 의 데이터를 가져오는 방식을 사용하면 자동으로 않니다 게시물로의 데이터 인코딩합니다 않습니다. Jquery 요청에 대한 사전 형식의 데이터를 안전하게 보낼 수 있을 것으로 기대하고 있다 첨부하려면 바디입니다 회선을 통해 직접.

[제크리스파람] 를 사용할 수 있는 솔루션 (http://api.jquery.com/jquery.param/) 함수를 작성할 수 있는 대부분의 스크립트입니다 쿼리 문자열 게시물로의 요청을 처리할 수 있을 것으로 기대하고 있다.

$.ajax({
    url: 'superman',
    type: 'POST',
    data: jQuery.param({ field1: "hello", field2 : "hello2"}) ,
    contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
    success: function (response) {
        alert(response.status);
    },
    error: function () {
        alert("error");
    }
}); 

이 경우 '매개 변수' 메서드입니다 형식식 데이터를 다음과 같이 사용된다.

field1=hello&field2=hello2

이 [이케리지아이아스] (http://api.jquery.com/jquery.ajax/) '라는 깃발을 붽뎄 프로스에스트라다 것인지 여부를 제어하는' 는 없다고 말했습니다. "고 이 문서를 자동으로 방관하겠나 인코딩입니다 완료되어도 데이텀이 설정값으로 'true' 로, 하지만 그 때 내가 아닌 비헤이비어를 준수하십시오 '포스트' 사용됩니다.

해설 (1)
    function FillData() {
    var param = $("#").val();
    $("#tbDetails").append("");
    $.ajax({
        type: "POST",/*method type*/
        contentType: "application/json; charset=utf-8",
        url: "Default.aspx/BindDatatable",/*Target function that will be return result*/
        data: '{"data":"' + param + '"}',/*parameter pass data is parameter name param is value */
        dataType: "json",
        success: function(data) {
               alert("Success");
            }
        },
        error: function(result) {
            alert("Error");
        }
    });   
}
해설 (0)

[게시물로의 요청] [1] 에서 매개변수입니다 전송되므로 인할지 본문에 요청, that& # 39 의 don& URL 에 # 39, 왜 그들을 볼 수 없다.

그들이 보고 싶은 경우, 변경

    type: 'POST',

    type: 'GET',

참고로 해당 코드를 가질 수 있는 브라우저 개발 툴 요청률 완료하십시오 문제를 볼 수 있습니다. # 39 의, 크롬, it& 의 &quot Network"; 패널.

[1]: http://en.wikipedia.org/wiki/POST_% 28HTTP% 29

해설 (0)
$.ajax(
   {
      type: 'post',
      url: 'superman',
      data: { 
        "field1": "hello",
        "field2": "hello1"
      },
      success: function (response) {
        alert("Success !!");
      },
      error: function () {
        alert("Error !!");
      }
   }
);
  • '유형: # 39, & # 39, POST& '는 요청을 매개변수입니다 덮어쓰기/추가 몸에 있는 동안 uirl 원하는거요 볼 수 없는' 유형: # 39, & # 39, GET& 첨부됩니다 ', 매개 변수를 URL 원하는거요 가시적입니다 *.

가장 인기 있는 웹 브라우저 컨테인먼트하는 네트워크 패널 reques 완료하십시오 표시합니다. .

일부 요청률 네트워크 패널 스어 볼 수 있습니다.

이를 통해 이 수행할 수도 있습니다.

$.post('superman',
      { 
        'field1': 'hello', 
        'field2': 'hello1'
      },
      function (response) {
        alert("Success !");
      }
    );
해설 (0)

사용 할 수 있어 스포스트 지아이아스 또는 $ $

$ 사용하여 지아이아스:

    $.ajax({
      type: 'post',
      url: 'superman',
      data: { 
        'field1': 'hello', 
        'field2': 'hello1'
      },
      success: function (response) {
        alert(response.status);
      },
      error: function () {
        alert("error");
      }
   });

$ 사용하여 스포스트:

    $.post('superman',
      { 
        'field1': 'hello', 
        'field2': 'hello1'
      },
      function (response, status) {
        alert(response.status);
      }
    );
해설 (1)

그러나 키를 써줬지 JSON 이 코드에 맞다고 반군지역 있지 않습니다.

주위에 또는 작은 따옴표 연산뿐 있어야 합니다

&gt. {&quot field1";: , &quot &quot hello&quot field2"; . &quot, hello2"}

$.ajax(
   {
      type: 'post',
      url: 'superman',
      data: { 
        "field1": "hello", // Quotes were missing
        "field2": "hello1" // Here also
      },
      success: function (response) {
        alert(response);
      },
      error: function () {
        alert("error");
      }
   }
);
해설 (0)

'포스트' 에 대해 간단히 추가할 수 있는 방법이 url 에서 전송하십시오 매개변수입니다 uirl 다음과 같습니다.

$.ajax({
    type: 'POST',
    url: 'superman?' + jQuery.param({ f1: "hello1", f2 : "hello2"}),
    // ...
}); 
해설 (1)