Jump to content
Forum Roportal
Sign in to follow this  
Vali29

Raspuns AJAX intr-o variabila

Rate this topic

Recommended Posts

Vreau ca cererea AJAX sa fie facută prin intermediul unei variabile.

 

Ex:

 

var x = request(url, parametri);

var y = request(url, parametri);

 

Pana acum am testat:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>test</title>
<script language="JavaScript" type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" charset="utf-8">
function request(){
	var myAjax = new Ajax.Request('test.php', {
						method: 'post',
						onComplete: showResponse});
					}
function showResponse(originalRequest){
	var newData = originalRequest.responseText;
	return newData;
}

function testare(){
	var out = request();
	alert(out);
}
</script>
</head>
<body>
<form id="test" name="test" action="" method="post">
<input type="button" name="some_name" value="Send" id="some_name" onclick="testare();" />
</form>
</body>

<?php
echo "Mesaj de test";
?>

 

Returneaza mesajul: "Undefined" :)

 

Mă poate ajuta cineva?

 

Aceeasi problema este dezbatuta si aici: http://otvety.google.ru/otvety/thread?tid=...%26tab%3Dwtmtod

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×