duanhao7786
2014-08-25 13:39
浏览 136
已采纳

将输入值传递给ajax获取Laravel

I am fairly new to Laravel and ajax in general, what I am trying to implement is to pass the value of an input field through an ajax get request. My request looks like this:

function getInfo() {

        $.ajax({
            url: "info",
            dataType: "json"
        }).success(function(data){
            $('#result').append(JSON.stringify(data));
        }).fail(function(){alert('Unable to fetch data!');;
        });
    }
    $('#infoSubmit').click(getInfo);

I have setup a route for my function in laravel that works like this public/info/Variable <--

When I add a variable after info/ I get the data for that variable (e.g profile name)

I need to pass this variable from an inputfield to ajax request to something like this: url: "info/+$inputfieldVariable"

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题