1

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 WebScriptEnablingBehavior 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.

0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for spotting that, I did have that wrong. Now both methods tell me "invalid label" which I'm not sure how to fix. Will probably have to create a new question as this one is solved by a single character :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.