Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello guys ,
Stuck at a problem for two days . The problem is that i am trying to hit a webservice from localhost .
Just for testing purposes i wrote this code and it ran the way it was supposed to :
<a href="http://www.zipdial.com/z2v/startTransaction.action?customerToken=mycustomertoken&clientTransactionId=1&callerid=9968280904&duration=180&countryCode=91&z2vToken=another_token">Save</a>

As you can see , everything is static and it works like a charm because i see something like this on the browser :
{"message":"ok","client_transaction_id":"2","transaction_token":"sometoken","status":"1","img":"http://www.zipdial.com/zip2auth/images/access/b8b7ad5781c6f07b775f623ab62f4f8d34f81570"}
Now i need to extract the img element from it but i have no idea in how to go about it .
I tried using jquery like this :
JavaScript
$(document).ready(function() {
     
		 alert('hello');

		 $.getJSON("http://www.zipdial.com/z2v/startTransaction.action?customerToken=mycustomertoken&clientTransactionId=2&callerid=9968280904&duration=180&countryCode=91&z2vToken=another_token",function(jd)
		{
			alert("hello again");
             alert(jd.image);
             
          });
	});

Now i only see the alert("hello") as a pop up but nothing inside the function call and on my browser i see this
"Origin http://server_name is not allowed by Access-Control-Allow-Origin."
Please help
Posted
Updated 27-Oct-12 8:16am
v2

1 solution

As I see, this is a cross-domain call. Thus a simple getJSON won't be enough. Consult the legacy ajax[^] method to see how you have to set parameters for a JSONP call.
 
Share this answer
 
Comments
Member 9459463 27-Oct-12 13:08pm    
Zoltan , i read the jsonp a bit ( i forgot to mention i am fairly new ) but according to that the server side code which i need to call should have a function which i could call . If that is the case then i cannot call the function as i can't change the code at that side . Am i right ?
Zoltán Zörgő 27-Oct-12 13:15pm    
Not absolutely necessary, forget JSONP for a second, and try it as a regular json call, but with CrossDomain settings. Shoul work.
Member 9459463 27-Oct-12 13:19pm    
How do i do that ?
Zoltán Zörgő 27-Oct-12 15:46pm    
http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900