Solved

Consuming RESTful web services with jQuery

Posted on 2011-02-14
10
1,107 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

828 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