Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Send and $_GET from Java Script to PHP?
    primarykey
    data
    text
    <p>I have made a Script sendsms.php which executes and sends SMS with HTTP API. I call sendsms.php with a Java script (Button) and get back results in a text input window.</p> <p>When I press my Java Button the phone number is automatically sent to sendsms.php and it executes. Below in my CODE you can see how the <strong>#phone</strong> is sent (with Java) and how its retrieved by sendsms.php</p> <p>My question is: Now I want add and SEND <strong>#nick_name</strong> together with <strong>#phone</strong>. How should I do that? </p> <p><strong>My Jave Button:</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('.smsbutton').click(function() { var val = $('#phone').val(); $.get('http://mydomain.com/sendsms.php', {phone: val}, function(data) { result = $.parseJSON(data); $("input[name='avaresultsms']").val(result.avaresultsms); }); }); }); &lt;/script&gt; &lt;br /&gt; &lt;input type="text" name="avaresultsms" value="" style="width: 370px;" readonly="readonly" /&gt; &lt;input id="smsbutton" name="smsbutton" type="button" class="smsbutton" value="SEND SMS"&gt; </code></pre> <p>And here is sendsms.php:</p> <pre><code>&lt;?php $phone = $_GET['phone']; $smstophone = str_replace("+", "", $phone); $sendapi = 'http://sms.com/api.php=sendsms&amp;user=MYUSERNAME&amp;password=MYPASS&amp;&amp;from=Escort%20Home&amp;to='.$smstophone.'&amp;text=Hello%20'.$nick_name.'%20Test1%20test2'; $smsrsult = file_get_contents($sendapi); $result['avaresultsms'] = $smsrsult; echo json_encode($result); ?&gt; </code></pre> <p>As you can see I use <code>var val = $('#phone').val();</code> in Java Button so with sendsms.php I can get it with: <code>$phone = $_GET['phone'];</code></p> <p>But now I also want to get <code>$nick_name = $_GET['nick_name'];</code> What should I add to Java script?</p> <p>Thank you very much for your help.</p> <p><strong>THIS WORKED FOR ME:</strong></p> <pre><code>var nickname = $('#nick_name').val(); $.get('http://mydomain.com/sendsms.php', {phone: val, nick_name: nickname}, function(data) { </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload