That does help, thanks.

I'm new to client side programming. Normally I do everything server side.

I've got a census data zipcode database sitting on server, and on that
server some javascript that when a zip code is filled in checks back
with the server for the city / state.

I also have used the reCaptcha javascript thing, and that can update
itself with a new captcha.

I thought I could make a relatively straightforward javascript library
to sharr this around my other sites without having to run server side
code and database everywhere. I don't seem to know which manual I
should be reading though.  Can someone give me a shove in the right
direction?

Thanks,
Chris


On 9/10/09, T.J. Crowder <t...@crowdersoftware.com> wrote:
>
> Hi,
>
> All relative URLs within a page (including ones in JavaScript Ajax
> calls) are resolved relative to the document's URL, not the script
> file's URL.  So "/zipcode.cgi" will resolve relative to the URL of the
> HTML document, which if I'm reading you correctly is on server 2.
> Hence the 404.
>
> To really hit server 1 instead, you'll have to use an *absolute* URL,
> but you'll also have to be using a browser that supports the new CORS
> initiative[1] (relatively few so far) and ensure that the servers are
> set up to return the appropriate CORS headers, otherwise by default
> you'll run into SOP[2] issues.
>
> [1] http://www.w3.org/TR/access-control/
> [2] http://en.wikipedia.org/wiki/Same_origin_policy
>
> HTH,
> --
> T.J. Crowder
> tj / crowder software / com
> www.crowdersoftware.com
>
>
> On Sep 9, 4:07 pm, MonkeyBoy <casny...@pennswoods.net> wrote:
>> I've got a fairly small zip code to city + state chunk of javascript
>> that I run on server 1, and call on server 2.
>>
>> I load prototype.js and my code (zipcode.js) from server 1 in some
>> html on server 2.  The problem comes when I make the Ajax.Updater
>> call, as it updates the page with a 404 error, and it is hitting the
>> zipcode.cgi on server 2 rather than on server 1.
>>
>> Any thoughts on what I'm doing wrong?
>>
>> The javascript in its entirety is thus:
>> function startupcitystate ()
>> {
>>     var citystateselector = $('citystateinput');
>>     citystateselector.update("<INPUT TYPE='text' NAME='zip'
>> ID='zipcode' onkeyup='checkZip();'>");
>>
>> }
>>
>> function checkZip()
>> {
>>     var citystateselector = $('citystateinput');
>>     if($F('zipcode').length == 5)
>>     {
>>         var url = '/zipcode.cgi';
>>         var params = 'zipcode=' + $F('zipcode');
>>         var ajax = new Ajax.Updater(
>>             'citystateinput',
>>              url,
>>              {method: 'get', parameters: params, onFailure:
>> reportError});
>>     }
>>
>> }
>>
>> function reportError(request)
>> {
>>     $F('citystateinput') = "Error";
>>
>> }
>>
>> startupcitystate();
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to