I Created a button that when onclick he delivering a prompt message in order The user will enter a free text. Now I need to use this free text and pass it as var input with GET method to external PHP in my system. I have tried using the getJSON method to do the following :
'<button onclick="SendFreeMSG()">Test MSG </button>
<p id="testMSG"></p>
<script>
function SendFreeMSG() {
var InputMessage= prompt("Please enter your Message", "Write down your message Here");
if (InputMessage!= null) {
document.getElementById("testMSG").innerHTML = "Your message is: " + InputMessage + " " ;
$.getJSON("sending_msg_to_user.php?userinput=" . $InputMessage ["userinput"] .
}
}
</script>' ;
The scrpit is working fine without the getJSON row, but when I tried it with that row nothing happen.
----- Addition ---- Here is another part of my code with click button and $getJSON In this part it is working well:
'<button onclick="' .
"if (confirm('sending message ?')) {
var activeValue = $(this).siblings('.all_users_active_value');" .
"var activeCaption = $(this).siblings('.all_users_active_caption');" .
"$.getJSON('sending_general_msg.php?General=" . $rowData['General'] .
"&active=' + (activeValue.html() == '1' ? '0' : '1'), " .
"function(data) { " .
"activeValue.html(data.active);" .
"activeCaption.html(data.active == 1 ? 'Active' : 'Inactive')" .
"})
} else {
alert('sending message cancelled')
};" .
"return false;".
'"> Sending new message </button>';
I will appreciate any help with that matter
Abraham