有人可以将代码转换为ASP格式吗?
<?php
$data = '
[
{
"A": "test",
"B": "test",
"C": "test"
},
{
"A": "test",
"B": "test",
"C": "test"
}
]
';
print($_GET['callback'] .'('. $data .')');
当我测试跨域限制解决方法时,这个代码与PHP服务器(当然)一起正常工作,我想在ASP环境下实现这个。 我试过这里http://www.me-u.com/php-asp/hosting/asp.php。 提前谢谢。
答案 0 :(得分:2)
喜欢,一次?
<%
Dim data
''// VBScript Strings cannot span multiple lines, we must use
''// concatenation ("&") and line continuation markers ("_")
''// (also, double quotes need to be escaped by *double* double quotes)
data = "" & _
"[" & _
" {" & _
" ""A"": ""test""," & vbCrLf & _
" ""B"": ""test""," & vbCrLf & _
" ""C"": ""test""" & vbCrLf & _
" }," & vbCrLf & _
" {" & vbCrLf & _
" ""A"": ""test""," & vbCrLf & _
" ""B"": ""test""," & vbCrLf & _
" ""C"": ""test""" & vbCrLf & _
" }" & vbCrLf & _
"]"
Response.Write Request.QueryString("callback") & "(" & data & ")"
%>
如果要打印所有字符串连接业务,可以避免整个字符串连接业务(例如,它没有进一步用于变量):
<%
Response.Write Request.QueryString("callback") & "("
%>
[
{
"A": "test",
"B": "test",
"C": "test"
},
{
"A": "test",
"B": "test",
"C": "test"
}
]
<%
Response.Write ")"
%>