How do I handle this problem?
Hi! all!
I wanna listen to the expert's advice. Can anyone solve this problem?
I couldn't use Callback Function's value in another functions.
Is this a Cross Domain problem?
----------------------------------------------------------------------------------------------------
Client Side
----------------------------------------------------------------------------------------------------
<script type="text/javascript" src="jquery-1.4.min.js"></script>
<script type="text/javascript">
var a;
$.ajax({
url : "
http://abc.com/a.php?callback=?",
type: 'GET',
dataType : 'jsonp',
success : function(data) {
window.a=data;
document.a=data;
alert(a.string); //Enable
test(a);
}
});
alert(a.string); //Disable
test = function(testString) {
alert(testString); // Enable
a=testString;
}
alert(a); // Disable
</script>
----------------------------------------------------------------------------------------------------
Server Side
----------------------------------------------------------------------------------------------------
Location :
http://abc.com/a.php<?
$json="{ \"string\" : \"this is String\"}";
echo $_GET['callback']."(".$json.")";
?>