Solved

Consuming RESTful web services with jQuery

Posted on 2011-02-14
10
1,102 Views
Last Modified: 2012-05-11
Greetings,

I need to find a tutorial on this topic, something that gives a well-defined, high-level view as well as (if possible) some actual coding examples to work through so I can get a feel for this type of work.  

Regarding details, I need something that (preferably) deals with the Zend Framework and output in JSON.

Thanks.
0
Comment
Question by:max7
  • 5
  • 3
  • 2
10 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 200 total points
ID: 34889915
0
 
LVL 1

Author Comment

by:max7
ID: 34897972
Thanks for that ... if I'm not mistaken, both links point to the same article.

Also, this tutorial deals only with ASMX which I believe is related to .NET web technology.  Anything related to PHP out there?
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34898500
actually it doesn't matter which is the server side technology, since the format of request and response is decided  by your rest service and protocol is anyways same http.

So, go ahead and try the same
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34903283
0
 
LVL 1

Author Comment

by:max7
ID: 34906980
>>>actually it doesn't matter which is the server side technology, since the format of request and response is decided  by your rest service and protocol is anyways same http.

So basically, are you saying that if the output is in JSON, the way jQuery would handle that response is the same, regardless whether or not it's a PHP or .NET backend?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Author Comment

by:max7
ID: 34907058
leakim971:  that's a great example but I don't see where jQuery is used to consume the web service.  Please pardon my ignorance if it's apparent but could you point it out to me?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34907126
You want to consume the wb at the server side (php/zend) or from the client side (jquery) ?
0
 
LVL 1

Author Comment

by:max7
ID: 34907878
I need to consume from the client side using jQuery.  the web services are RESTful and output JSON.
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 300 total points
ID: 34908102
with jQuery this can be a simple line : http://api.jquery.com/jQuery.getJSON/

You need to have the same domain and protocol for the client and the server ( url in the browser and url in the ajax call $.getJSON(url,callbackFunction

else you need to handle JSONP on the server or use a proxy

$.getJSON("/path/to/webservice/youfunction/param1", function(data) {
      // do something with the data back if needed
});

Open in new window

0
 
LVL 1

Author Closing Comment

by:max7
ID: 34909819
Undoubtedly, I will have more questions on this topic but for now this is a good start.  Thanks to you both.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now