【发布时间】:2013-10-19 08:51:18
【问题描述】:
如何将 yes 或 no 值返回给 php 函数。如果不能,我可以使用 curl 执行相同的 jsonp 功能吗?
$.ajax({
url: 'www.example.com/trck.php',
type: 'GET',
data: 'adrs='+getHost( document.domain ),
dataType: 'jsonp',
jsonp: false,
jsonpCallback: 'methodCallback',
success: function( data ) {
if( data.message == "yes" ) { return yes;
} else {
return no;
}
},
error: function( error ) {
console.log( error );
}
});
通过return the value **yes** or **no** to php function 行我的意思是我可以拥有一个调用上述ajax 脚本的php 函数来获取它的返回值..
编辑
经过一番研究,我知道我无法将 ajax 值返回给 php 函数。
我可以在 curl 中使用与 ajax 相同的功能吗?
【问题讨论】:
-
返回什么PHP函数?您需要为此进行另一个 AJAX 调用......或者实际上只是使用 trck.php
-
不清楚你想要做什么或你真正想要什么。
-
@ZathrusWriter 不是另一个 ajax 调用或不是 trck.php .. 请参阅我更新的问题
-
您不能在 php 函数中包含 jquery/javascript 代码并从中返回值... PHP 在服务器端,而 Javascript/jquery 在客户端!!!
-
@AyyappanSekar 谢谢..我可以用 curl 做同样的 jsonp 功能吗...?我认为使用 curl 而不是 ajax jsonp 可以将值返回给 php 函数?对吗?