How do I call a web service from javascript

后端 未结 2 794
闹比i
闹比i 2020-12-14 04:08

Say I have a web service http://www.example.com/webservice.pl?q=google which returns text \"google.com\". I need to call this web service (http://www.example.com/webservice.

2条回答
  •  既然无缘
    2020-12-14 04:39

    Take a look at one of the many javascript libraries out there. I'd recommend jQuery, personally. Aside from all the fancy UI stuff they can do, it has really good cross-browser AJAX libraries.

    $.get(
        "http://xyz.com/webservice.pl",
        { q : "google" },
        function(data) {
            alert(data);  // "google.com"
        }
    );
    

提交回复
热议问题