i am trying to develop a wp plugin that will send a variable to my server. So far if i use my code bellow as seperate php file and not within my script works great.. it sends the variables and recieve the results from remote php file.
If i put the same code in my custom wp plugin it doesn't recieve anything.
my code:
<script>
jQuery(document).ready(function(){
jQuery(".adminpnlnshbutton").click(function(){
var usermail = jQuery('#uemail').val();
var userkey = jQuery('#ukey').val();
var dataString = 'usermail='+ usermail + '&userkey='+ userkey;
$.ajax({
type: "POST",
url: "http://ift.tt/1S0Chtd",
data: dataString,
crossDomain: true,
dataType: 'html',
success: function(data) {
alert (data);
}
});
});
});
</script>
And check php:
$m = $_POST['usermail'];
$k = $_POST['userkey'];
$s = " | ";
echo $m . $s . $k;
As wordpress plugin:
<?
add_action('admin_menu', 'test_plugin_setup_menu');
function test_plugin_setup_menu(){
add_menu_page( 'Test Plugin Page', 'Tes Plugin', 'manage_options', 'test-plugin', 'test_init' );
}
function test_init(){
if (is_user_logged_in()) {
?>
<input name="uemail" type="text" id="uemail" value="email" />
<input name="ukey" type="text" id="ukey" value="activation key" />
<div class="adminpnlnshbutton">SEND</div>
<script>
jQuery(document).ready(function(){
jQuery(".adminpnlnshbutton").click(function(){
var usermail = jQuery('#uemail').val();
var userkey = jQuery('#ukey').val();
var dataString = 'usermail='+ usermail + '&userkey='+ userkey;
$.ajax({
type: "POST",
url: "http://ift.tt/1S0Chtd",
data: dataString,
crossDomain: true,
dataType: 'html',
success: function(data) {
alert (data);
}
});
});
});
</script>
<?
}
}
?>
any idea why i can't recieve the data inside my plugin?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire