Before giving practical solutions, I'd like to invite you to think about this question. Is this a server-side or a client-side matter? In other words, does this have to do with the server-response or the server-request?
It's obvious that it's server-side because it has to do with the server-response. How do you get the server to send only the value you need? The reply above gives you a valid solution in PHP. Another solution would be checking the $_GET[] variable to see whether "task" is set to "checkname" and respond according that info. if ($_GET['task'] == 'checkname') { // print var; } else { // print page; } A more sophisticated way of handling this would be using the switch- statement. switch ($_GET['task']) { case 'checkname': { // print var; } break; case 'page': // fall-through default: { // print page } break; } Or you simply create a new file that explicitly handles AJAX requests. HTH, Rick luigi7up wrote: > Hello everyone, > > Is it possible to send ajax call for somefile.php and get just value > of one php variable generated by that server > > script? > > Example: > > $.post( blog.php?task=checkname, > > {ime:$(\"#ime\").val()}, > function(msg){ > alert(msg); > }); > > This ajax call will get whole page ( blog.php?task=checkname) as a > result but I want value of just one variable. > > I know I could create a separate file "ajaxCheck.php" that would > return HTML I could reuse in my javaScript > > but I want to solve this this way. > > Im probbably using wrong method POST & GET. Should I be using jSON?! > How do I use it for this purposes > > Thank you > > Luka