我创建了一个c#ASP.Net JSON WebService.但是我从这个WebService读取数据时遇到了很大麻烦,因为在我看来输出不是有效的JSON格式?
通常你应该将[对象,对象]作为数据返回.但我得到[对象,文件]我做错了什么或我错过了什么?
我当前的输出如下所示:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">{
"Email": "james@example.com",
"Active": true,
"CreatedDate": "2013-01-20T00:00:00Z",
"Roles": [
"User",
"Admin"
]
}</string>
Run Code Online (Sandbox Code Playgroud)
这是我的JQuery-Ajax调用:
$.ajax({
type: "GET",
//dataType: "json", <-- When I uncomment this line the request fails :(
url: "http://webservices.domain.local/service.asmx/getData?name=",
success: function(data){
console.log(data); // Output is: [object Document] instead of [object, object]
},
error: function(XMLHttpRequest, textStatus, errorThrown){
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的WebService的代码:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Web.Services; …Run Code Online (Sandbox Code Playgroud) 我怎么能写下以下所有浏览器都支持的代码?因为似乎IE8中不支持forEach-Function ...
digits.forEach( function( value, index ) {
// create a span with initial conditions
var span = $( '<span>', {
'class': 'digit0',
'data': {
'current': 0,
'goal' : value
}
} );
// append span to the div#number
span.appendTo( $( 'div#number' ) );
// call countUp after interval multiplied by the index of this span
setTimeout( function() { countUp.call( span ); }, index * interval );
} );
Run Code Online (Sandbox Code Playgroud)
请在此处查看完整的代码:http://jsfiddle.net/bBadM/(它不适用于所有浏览器)在此先感谢.
问候,
我有一个包含文件URL的字符串.从那个字符串我喜欢只获得没有扩展名的文件名.
例如:
http://path/Lists/Test/Attachments/1/Document Test.docx
Run Code Online (Sandbox Code Playgroud)
从那个例子我喜欢回来: Document Test
我已经有了以下模式:
(?<=\/)(\w+)(?=\.\w+(\?.*)*$)
Run Code Online (Sandbox Code Playgroud)
但是如果文件名包含空格则不起作用...如何更改此模式更灵活?
我使用以下代码来读取XML文件:
XDocument doc = XDocument.Load(xmlPath);
foreach (var node in doc.Descendants("LogInfo"))
{
ListViewItem item = new ListViewItem(new string[]
{
node.Element("MailBox").Value,
node.Element("LastRun").Value,
});
listViewHome.Items.Add(item);
}
Run Code Online (Sandbox Code Playgroud)
如何更改此代码以仅接收该XML文件中最后一个"n"个元素?提前致谢.