Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic question on Ajax.Request

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
0
0
AU
I am a noob on this sort of thing. Have looked on web but info is pretty deep an there aren't many "just do this" pages.

I wish to use a site where when I POST information to the site it does whatever in the backend and returns a HTML page with text something like 1234|OK|success

I understand that I start with something like

Code:
var url = encodeURIComponent('checkuser.php&var=something&var2=something else');
		
    new Ajax.Request(url, {
       method: 'post', onSuccess: function(transport) {

       then parse transport.responseText 
       }
    });

But from there I have to confess to being completely lost. In fact I am certain that that isn't really right. Is there a tutorial anywhere?

Thanks in advance.


Steve
- I have fun with telemarketers
 
You've got the client-side all sorted, so now it's just the server-side portion. You would need to ask that in whatever forum is best suited for the server-side technology you're using (e.g. ASP, JSP, etc).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for that.

In fact since I posted it I have learned a lot about ajax.request. I had no idea there was this rich set of classes and methods behind it all.

In fact my little app is 'almost' working now. Perhaps you can help with this side of it.

When I use it to retrieve data from my test PHP page it works perfectly, returns the result expected in responseText. But when I try to connect to the real site I am going to use it fails.

However...if I take the URL that it is trying to connect with (including the parameters) and paste it in a browser it works as expected, so I know the URL is well formed.

It appears to me that the problem has something to do with the encodeURIComponent, here's why:

if I try to connect to my test page (which contains a simple test string) with encodeURIComponent(testpage) it breaks (not fails) but if I remove the encodeURIComponent() it works.

Conversely if I connect to the real site, which is a https: page, with encodeURIComponent() it actually fails (hits onFailure:) but if I remove the encodeURIComponent() then it breaks.

i am caught somewhere between shouting from frustration and sighing from failure :p

I know I will nut it out eventually but it is exhausting. Will likely be a really obvious error no doubt.

Any thoughts/suggestions appreciated.



Steve
- I have fun with telemarketers
 
Since you seem to be using prototype, try this instead:

Code:
var url = 'checkuser.php';
var params = 'var=' + escape('something') + '&var2=' + escape('something else');
        
new Ajax.Request(
   url, {
      method: 'post',
      parameters: params,
      onSuccess: function(transport) { }
   }
);

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top