开发者

WCF Service with JSONP response jQuery problems

I'm new to JSONP and Ajax/JQuery. I've searched high and low for an answer and can't find anything out there.

I have a self hosted WCF service setup with WebHTTPBinding with Web开发者_开发知识库ScriptEnablingBehavior enabled. My service is running and I can goto my url "http://e-invizion:8801/csecontrol/v1/GetTestString" and Firefox prompts to download a file, so I open that file in notepad and the contents are "{"d":"6/28/2011 12:10:23 AM"}" which is just the current date and time returned as a string from the server. So that seems to be working fine.

If I query like:

$.ajax({
    url: "http://e-invizion:8801/csecontrol/v1/GetTestString&callback=?",
    dataType: "jsonp",
    type: "GET",
    cache: false
    },
    function(data){
        console.log(data);
    });    

This gets ingested into the head of the page, a new one for each time I press the button:

<script async="" src="http://e-invizion:8801/csecontrol/v1/GetTestString&
callback=jQuery16102834440269703241_1309242056366?_=1309242057876">
<HTML><HEAD><STYLE>snip...</STYLE>
<TITLE>Service</TITLE></HEAD><BODY>
<DIV id="content">
<P class="heading1">Service</P>
<BR/>
<P class="intro">Endpoint not found.</P>
</DIV>
</BODY></HTML>
</script>

If I query like:

$.getJSON("http://e-invizion:8801/csecontrol/v1/GetTestString?callback=?", getNowPlayingResponse);

I get this in Firebug console:

invalid label
    {"d":"6\/28\/2011 1:23:21 AM"}

I'm trying to get this callback working for JSONP but I'm just at a loss on what I'm missing.


seems like your url is wrong

$.ajax({
    url: "http://e-invizion:8801/csecontrol/v1/GetTestString?callback=?",
    dataType: "jsonp",
    type: "GET",
    cache: false
    },
    function(data){
        console.log(data);
    });    

i changed the GetTestString&callback... to GetTestString?callback... hopefully this was the problem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜