This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes HTTP request question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTTP request question" Watch "HTTP request question" New topic
Author

HTTP request question

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
hi,

I have the javascript code like this:


I do not know why it does not work in case 1, I tried to make different ajax calls using this same doSentRequest method, which I need transfer the call back function name.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61594
    
  67

If you do not have a function named callBackFunctionName why would you expect it to work? There's certainly got to be much more to this question than you've posted.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Thank you Bear, i thought " handleResponse " was transferred as "scan.do" does. My mind does not work well sometimes these days (worked 14 hours yesterday), i have to finish a project with a very tight schedule, and i have many things to learn.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61594
    
  67

No. There's no magic just because this is Ajax. All the normal rules of JavaScript still apply.

If you want what you have there to work, you need to pass a reference to the callback function to your doSendRequest function, not a string. A string is a string and can't magically become a function. (The string could be used to look up the function definition, but that's another show.)

But the more basic question I'd ask is: why are you doing your own Ajax rather than letting jQuery or Dojo handle it?
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Thank you Bear for the info.

One reason I did not choose jquery/dojo is license conern. The other reason is that I took a look at jquery/dojo, and feels that the tight time i have do not allow me to learn/use it, maybe i am wrong. Anyway, thanks for help!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61594
    
  67

david arnold wrote:One reason I did not choose jquery/dojo is license conern.

What license concern? There is no license concern.

i have do not allow me to learn/use it

Do you have time to deal with all the nuances and cross-browser issues that Ajax has on your own?
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
from my understanding, if I use GPL license in a project A, person A buy this project from me and he can use it, but he can not sell it to others, right?

I do not know much about Ajax cross browser issue, and i have not got chance to test cross browser so far, i only have simple http request browser check. Any big issue i need to know?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61594
    
  67

david arnold wrote:from my understanding, if I use GPL license in a project A, person A buy this project from me and he can use it, but he can not sell it to others, right?

And which product are you concerned about being released under a GPL license?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are thinking that you can assign multiple function calls.



That code above is the same thing as



Would you expect to see both 1 and 2?

Eric
 
Consider Paul's rocket mass heater.
 
subject: HTTP request question