简体   繁体   中英

How to send GET values without redirecting user to that URL page?

I want to send GET values to another script so that the script takes those GET values and create a PDF as per it and sends to the user email. I just need how can I send GET values in URL using JavaScript without redirecting to the URL you send GET values with.

If anyone can help me here using JavaScript or jQuery. It will be a great help.

This is the button. It's not a form.

<a href="javascript:" id="wpe_btnOrder" class="btn btn-wide btn-primary" data-tldinit="true"><span class="fa fa-check" data-tldinit="true"></span>SEND ME THE PDF<canvas class="lfb_shineCanvas" data-tldinit="true" width="202" height="41" style="border-radius: 4px;"></canvas></a>

This is how I want to send the values:

https://scripts.google.com/?name=name

Try this:

$.ajax({
  url: "your url",
  type: "get", //send it through get method
  data: { 
    name: "put the name value here", 
  },
  success: function(response) {
    //Do Something
  },
  error: function(xhr) {
    //Do Something to handle error
  }
});

使用jQuery的最简单形式的get调用

$.get('your_function.php', {'var':'value'}, function() {}); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM