dongzong5017 2018-07-17 07:20
浏览 84
已采纳

有没有办法转换文本框值并分配给PHP变量?

My goal is to get some of the value from ajax data to assign in php variable. As you can see the ajax code below, i could pass the value through a class (edit_id). How to put the value from the textbox to a php variable?

Ajax

$.ajax({
        type: 'POST',
        url: "{{ URL::route('test') }}",
        headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}' },
        data: { "camp_id" : camp_id },
        success: function(data){
          if(data.data.success){
                $('#edit_id').val(data.data.success.id);
                $('#edit_desc').val(data.data.success.description);
                console.log(data.data.success.id); // this will output the id eg. 1
                console.log(data.data.success.description); // this will output the description eg. hello world
          }
        }
});

View

<input type="text" class="form-control" id="edit_id" name="id"> //will diplay textbox with value
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何修改为正确的?求解决
      • ¥15 django访问管理员界面问题
      • ¥20 python homework完成
      • ¥20 求解 多变量系统的最小二乘辨识问题的推导以及matlab仿真
      • ¥15 arduino esp8266 Blinker编译报问题
      • ¥15 ubuntu18.04运行模型,直接死机
      • ¥30 (问卷调查)莫名其妙丢了u盘,你们会是什么心理状态
      • ¥100 Spark+android应⽤案例
      • ¥15 yolov8 目标检测 重叠 遮挡
      • ¥20 微信聊天记录如何部署到服务器上