执行sparql查询到JS脚本时出错?

时间:2017-12-02 21:58:24

标签: javascript jquery ajax sparql dbpedia

从sparql开始,希望在我的" abstract"中执行显示的SPARQL查询。 div,我遇到了一个我无法消除的错误。 所以我发布我的消息以获得意见(和解决方案?)最终显示我的请求的结果。

这是我的错误:

  

jquery.min.js:4 GET   http://dbpedia.org/sparql?query=PREFIX%20dbpedia2%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%20PREFIX%20Abs%3A%20%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%20SELECT%20%3Fabstract%20WHERE%20%7B%20%3Fs%20dbpedia2%3ACivil_engineeringe%22%40en%3B%20Abs%3Aabstract%20%3Fabstract%20%7D&format=json&callback=jQuery111006239110193011803_1512251513037&_=1512251513038   净:: ERR_ABORTED

这是我的剧本:

public class StateObject
{
    public Socket workSocket = null;
    public const int BufferSize = 4096;
    public byte[] buffer = new byte[BufferSize];
    public StringBuilder sb = new StringBuilder();
}

public class TcpServerAsync
{
    public readonly ConcurrentQueue<String> queue = new ConcurrentQueue<String>();
    public ManualResetEvent allDone = new ManualResetEvent(false);
    private Boolean _isRunning = true;

    public event EventHandler Connected;

    public TcpServerAsync(Int32 port)
    {
    }

    public void Start()
    {
        Thread t = new Thread(Run);
        t.Start();
    }

    public void Run()
    {
        IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost");
        IPAddress ipAddress = ipHostInfo.AddressList[1];
        IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 5000);
        Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

        try
        {
            listener.Bind(localEndPoint);
            listener.Listen(1);

            while (_isRunning)
            {
                allDone.Reset();
                listener.BeginAccept(new AsyncCallback(AcceptCallback), listener);
                allDone.WaitOne();
            }
        }
        catch (Exception e)
        {
            Debug.WriteLine(e.ToString());
        }
    }

    public void AcceptCallback(IAsyncResult ar)
    {
        allDone.Set();

        Connected.Invoke(this, new EventArgs());
        Socket listener = (Socket)ar.AsyncState;
        Socket handler = listener.EndAccept(ar);

        StateObject state = new StateObject
        {
            workSocket = handler
        };
        handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state);

        while (handler.Connected)
        {
            if (queue.TryDequeue(out String data))
            {
                try
                {
                    SendData(handler, data);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            Thread.Sleep(0); 
        }
    }

    public void ReadCallback(IAsyncResult ar)
    {
        String content = String.Empty;

        StateObject state = (StateObject)ar.AsyncState;
        Socket handler = state.workSocket;

        int bytesRead = handler.EndReceive(ar);

        if (bytesRead > 0)
        {
            state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead));
            content = state.sb.ToString();
            Debug.WriteLine("Read {0} bytes from socket. \n Data : {1}", content.Length, content);
        }
    }

    public void SendData(Socket handler, String data)
    {
        byte[] byteData = Encoding.ASCII.GetBytes(data);
        handler.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), handler);
    }

    private void SendCallback(IAsyncResult ar)
    {
        try
        {
            Socket handler = (Socket)ar.AsyncState;

            int bytesSent = handler.EndSend(ar);
            Debug.WriteLine("Sent {0} bytes to client.", bytesSent);
        }
        catch (Exception e)
        {
            Debug.WriteLine(e.ToString());
        }
    }
}

0 个答案:

没有答案