jquery getJson not passing any values to controller

前端 未结 2 841
[愿得一人]
[愿得一人] 2021-01-02 14:52

I am trying to pass some text from a textbox to a controller to get JSON results like so

function invokeAction() {
        var searchText = $(\"#SearchTextBo         


        
2条回答
  •  独厮守ぢ
    2021-01-02 15:10

    I've had some problems returning json from services and I wasn't getting any calls back. it turned out that the json was malformed and I was able to test that and get those errors by handling the error option of the plain ajax call.

    $.ajax({
      type: "GET",
      url: "Home/Results/",
      data: { search: searchText },
      dataType: "json",
      error: function(xhr, status, error) {
        // you may need to handle me if the json is invalid
        // this is the ajax object
      },
      success: function(json){
        alert( "Data Returned: " + json);
      }
    });
    

提交回复
热议问题