CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Ajax and Design (http://www.codingforums.com/forumdisplay.php?f=55)
-   -   how we pass more than one parameter in ajax.request (http://www.codingforums.com/showthread.php?t=161968)

vkdixit 03-23-2009 12:52 PM

how we pass more than one parameter in ajax.request
 
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 01: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 03:30 PM

that looks like prototype to me.

what exactly are you trying to accomplish?

bdl 03-24-2009 04: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:
Code:

$.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 03: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

Code:

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


All times are GMT +1. The time now is 06:54 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.