joker
joker

Reputation: 74

why Whatsapp web api not sending &?

I'm using this Javascript to send some information to someone on whatsapp but don't know why Javascript is not sending my message after using & I write it after company name. it is very necessary to use this in middle of the text. what should I do?

I want to use & after conpnayName so I can deliver what I want to the my client.

function whatsapp(){
  

   var compnayName = $("input[name=companyName]").val();  
   var p_number = $("input[name=p_number]").val();  


   console.log(s_no)


   window.open( "https://api.whatsapp.com/send?phone=+91"+ p_number +"&text="  +"Download Your Bill from : http://localhost/learn/php_invoice/search-bill.php?order_id="+ compnayName + "&" + "p_number" + p_number  ,'_blank');

}

Upvotes: 0

Views: 885

Answers (1)

DJ Hemath
DJ Hemath

Reputation: 662

You should url encode the "&" for that specific symbol. Take a look at url encoding https://www.w3schools.com/tags/ref_urlencode.asp

Try something like,

window.open( "https://api.whatsapp.com/send?phone=+91"+ p_number +"&text="  +"Download Your Bill from : http://localhost/learn/php_invoice/search-bill.php?order_id="+ compnayName + "%26" + "p_number" + p_number  ,'_blank');

Here "%26" refers to "&".

Upvotes: 3

Related Questions