0

I'm looking to create a proper postback for an affiliate system. It's quite similar a request to:

Grab a section from a URL and append it a link using jQuery

But it's a little beyond me to capture it the same way. The basic link I need to call in a hidden image tag or JavaScript on a thank you page is:

<img border="0" src="http://example.com/idevaffiliate/sale.php?profile=12345&idev_saleamt=123&idev_ordernum=VALUE" width="1" height="1">

or

<script language="JavaScript" type="text/javascript" src="http://example.com/idevaffiliate/sale.php?profile=12345&idev_saleamt=123&idev_ordernum=VALUE"></script>

Now, I've got all the other variables down, but the e-mail address that I need to append under ordernum will be a part of the link generated by aWeber on the thank you page, as such:

http://example.com/welcome?email=johndoe@mailserver.com

Now, aWeber offers this instruction:

https://help.aweber.com/hc/en-us/articles/204027506-How-Do-I-Display-Subscribers-Names-Or-Email-Addresses-On-My-Thank-You-Page-

And I'm sure I can't just go and add this to the url:

http://example.com/idevaffiliate/sale.php?profile=12345&idev_saleamt=123&idev_ordernum=<script type="text/javascript">formData.display("email")</script>

I'm really struggling to find anything relevant online. Any help is more than welcome. Thanks!

Community
  • 1
  • 1
Vuk Pop
  • 3
  • 3

1 Answers1

0

Is this what you are looking for?

//Set email address to variable email
var email = mail@mail.com;

//Get content (value) of `src`-attribute and put it into src-variable
var src = $("script[lang='JavaScript']").attr("src");

//Replace VALUE with and put it into newSrc -variable
var newSrc = src.replace('VALUE',email);

//Check if ok
console.log(newSrc);

/********/
/*UPDATE*/
/********/
//replace old src with newSrc
$("script[lang='JavaScript']").attr("src", newSrc);
Shamppi
  • 447
  • 4
  • 16
  • Hi. Thanks for the answer. Could you be more specific? I understand where you're going with this, but where do I put it? In the header of the ty page or the form? – Vuk Pop Aug 15 '16 at 10:32
  • @VukPop, I updated my answer. You can put it anywhere you wish - The updated answer puts it to the original script source, but you can define it to any other element too. Does this help? – Shamppi Aug 17 '16 at 12:10
  • looks good. I'll try it out over the weekend some more before I put it on the live server. thanks! I'll check if it works well, and let you know by Monday. :D – Vuk Pop Aug 18 '16 at 20:32
  • OK, so the thing is, that I needed this loaded with the page properly, and this didn't work for me. However, thanks to your idea, I did get around to using PHP to get it done. Here's the code I used: if ( !empty($_GET['email']) ){ echo $_GET['email']; – Vuk Pop Aug 22 '16 at 23:02
  • Ok! Good that you got it working and thanks for approving the answer :) – Shamppi Aug 23 '16 at 10:26