How to develop plugin with ajax
-
Dear all,
I develop one plugin and I used ajax as below in my plugin file:
<script type=”text/javascript” src=”http://code.jquery.com/jquery-latest.js”></script>
<script type=”text/javascript”>
$(document).ready(function() {
$(“#user_login”).blur(function() { // when focus out
$(“#message”).html(“checking username…”); //before AJAX response
var form_data = {
action: “check_username”,
username: $(this).val()
};
$.ajax({
type: “POST”,
url: “functions.php”,
data: form_data,
success: function(result) {
$(“#message”).html(result);
}
});});
});
</script>When I deactivate it works normally but when I active in show an error like this:
The plugin generated 3 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
I think this error because of the Javascript Code it provide some space to php file.
My question is: How can we put javascript code into plugin file?
The topic ‘How to develop plugin with ajax’ is closed to new replies.