How to make cross domain SOAP query using jQuery

I am using a SOAP web service to get a response from another server. I am using jQuery ajax to get data from the server. But I get a 0 (zero) status code from the server.

How do I get ajax call forwarding using jQuery?

+4
source share
2 answers

Instead of trying to get cross-domain data using jQuery, try to get data using PHP or another language that allows cross-domain access. Create a PHP page that loads SOAP data, and use jQuery to embed this information in your page. Although this is not a SOAP connection, to illustrate this idea, you can create this PHP page to download Youtube videos:

<?php $vid = filter_var($_POST['id'], FILTER_SANITIZE_STRING); ?> <?php if ($vid) : ?> <iframe title="YouTube video player" width="510" height="317" src="http://www.youtube.com/embed/<?php echo $vid; ?>?autoplay=1" frameborder="0" allowfullscreen></iframe> <?php endif; ?> 

Then use jQuery to display it - clicking a link can call this function:

 function loadContent() { $(this).parent().load("/youtube-video.php",{id:video_id},showNewContent()); } 
+1
source

Your question seems very vague. but below this is one way to do a cross-domain query in jQuery:

 $(function() { $.ajax({ type:'GET', dataType:'jsonp', jsonp:'jsonp', url:'http://api.stackoverflow.com/1.0/tags/', success:function(data) { $.each(data["tags"], function(index, item) { var $tag = item.name; var $count = item.count; $("body").append('<div class="stackoverflow"> The Tag <span class="q-tag">' + $tag + '</span> has < span class="q-count">' + $count + '</span> Questions.</div>') }); }, error:function() { alert("Sorry, I can't get the feed"); } }); }); 

Demo

DESCRIPTION ABOVE

0
source

All Articles