javascript - How to bring parameters in $.get request so that serverLet can receive data?
仅有的幸福
仅有的幸福 2017-05-19 10:35:13
0
2
585

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(){
  
});
仅有的幸福
仅有的幸福

reply all(2)
给我你的怀抱

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()})
  });
过去多啦不再A梦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template