search

Home  >  Q&A  >  body text

javascript - How to bring parameters in $.get request so that serverLet can receive data?

Specific business scenario:
When I click the button, I will use the $.get method to request a pop-up page. After filling in the content of the pop-up page, I click the confirmation button in the pop-up window and need to pass parameters to the server. What should you do in this situation?

demo address

Directory Structure:

index.js code:

var bground = $('<p class="dialog-bg"><p class="btn-group"></p></p>');
var sure_btn = $("<button>确认</button>");
var off_btn = $("<button>取消</button>");

$(".btn").on("click",function(){
          alert("1");
        var sUrl = "../snippet/child.html";
  $(".btn-group").append(sure_btn).append(off_btn);
  $.get(sUrl,function(obj){
    var full = bground.append(obj);
    $(document).append(full);
  });
});

// 确认按钮
sure_btn.on("click",function(){
  
});

// 取消按钮
off_btn.on("click",function(){
  
});
仅有的幸福仅有的幸福2865 days ago614

reply all(2)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-19 10:37:13

    I don’t quite understand the meaning of the question. What’s the problem?
    After append after $.get(), after filling in, just submit the form directly

      $.get(sUrl,function(obj){
        var full = bground.append(obj);
        $(document).append(full);
        //提交表单(伪代码)
        let user = $('#user').value;
        $('#submit').click(()=>{$.ajax({........}).then()})
      });

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:37:13

    If two parameters, name and age, are passed, sUrl="../snippet/child.html?name=tom&age=18";
    This?

    reply
    0
  • Cancelreply