...

View Full Version : how we pass more than one parameter in ajax.request



vkdixit
03-23-2009, 01:52 PM
Hi all,
Plz help me how we pass the parameter in ajax.request and get the oncomplete text...........


var ajaxc = new Ajax.Request('/bc/krnlAddComment1.asp?ID=<%=request("ID")%>comment=comm&name=myname',{
method: 'get',
parameters: 'true',
onSuccess: function handleresponsemess(request)
{
alert('great');
return false;
}
});

Fou-Lu
03-23-2009, 02:09 PM
I'm guessing this is from a JS framework of some sorts.
Java is not the same as javascript. Moving to AJAX forum.

ohgod
03-23-2009, 04:30 PM
that looks like prototype to me.

what exactly are you trying to accomplish?

bdl
03-24-2009, 05:28 AM
I'm assuming the OP is referring to sending the query string data, namely ID, comment and name to the request. As Fou-Lu mentioned, this is obviously a call to some framework's Ajax request, so the documentation on that framework should spell it out. For example, here's how you would do it in jquery:


$.ajax( {
type : "POST",
url : theUrl,
data : "ID=theID&comment=comment&name=theName",
success : function(data) {
$("#returnData").append("<p/>").html(data);
},
failure : function(err) {
console.log(err);
}
} );

ohgod
03-25-2009, 04:07 PM
ooohh... don't attach your parameters to your url string. the url string should just be your target file. you CAN technically do it that way i think... but i'd suggest following the api docs. instead of using parameters = "true" (which isn't right) use parameters: 'ID=<%=request("ID")%>comment=comm&name=myname'

the returned text will be in transport.responseText

so


var ajaxc = new Ajax.Request('/bc/krnlAddComment1.asp',{
method: 'get',
parameters: 'ID=<%=request("ID")%>comment=comm&name=myname',
onSuccess: function (transport)
{
alert(transport.responseText);
}
});

http://www.prototypejs.org/api/ajax/request



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum