-2

i want to check username in database whether it is there or not while typing

i wrote php coding in same page..i have taken the username by javascript like var x=document.getElementById("username").value;

now how to pass value to php code.please give suggestion for this.

0

1 Answer 1

0

you can use jQuery $.getJson and send Json Object to PHP script and use it there. The PHP can return Json value back to the Javascript so it can know how to handle it.

$.getJson('php_script.php', '{username:username}', function (returnJson) {
//here you do what you want with the returnJson object
}
Sign up to request clarification or add additional context in comments.

1 Comment

'{username:username}' is neither JSON nor an object. I suggest to pass an object ({username:username}), so that PHP can access the value via $_GET['username'].

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.