Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4098536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:18:53+00:00 2026-05-20T20:18:53+00:00

Can someone please explain the following. I’ve scoured the net for ages trying to

  • 0

Can someone please explain the following. I’ve scoured the net for ages trying to find help and I believe I’m doing everything correctly but still getting errors.

I have the following script on my page:

        function GetPageAdvert2(url) {

            $.getJSON('http://url/servicename.asmx/CheckAdvert?callback=?', 
            {
                pagename:   url,
                success:    function(data) { alert(data) }
            });        
        };

And my webservice returns nothing more than:

jsonp1301065851157('url/KiN_150x300.jpg');

The problem is that when I call GetPageAdvert2, nothing is happening.

My WebService (written in VB.Net) is:

        <WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, XmlSerializeString:=False, UseHttpGet:=True)> _
Public Sub CheckAdvert(ByVal pagename As String, ByVal callback As String)

    Dim pageUID As Integer = 0
    Dim advertURL As List(Of aU) = New List(Of aU)()

    Dim sss As String

    Using con As New System.Data.SqlClient.SqlConnection(My.Settings.sqlConnection2)

           SQL STUFF IN HERE
           the SELECT statement will return a value and place it in Variable SSS


    End Using

    Context.Response.ContentType = "application/json"
    Context.Response.Write(callback & "('" & sss & "');")
    Context.Response.End()


End Function

The response I’m getting back (in FF) is:

PARAMS:
callback    jsonp1300979718942
contentType application/json; charset=utf-8
pagename    default.html
success undefined

RESPONSE:
jsonp1301065851157('url/KiN_150x300.jpg');

This is mostly, what I believe, to be correct.

However the “Alert(data)” isn’t producing anything other than “undefined”.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:18:54+00:00Added an answer on May 20, 2026 at 8:18 pm

    When using JSONP, you can’t simply return a JSON string, as the string returned will actually get injected into the current page in a new script element. You need to return a valid JavaScript statement that calls a callback handler, in which the response is parsed.

    There’s an example on the Wikipedia page:

    parseResponse({"Name": "Cheeso", Id : 1823, "Rank": 7})
    

    Note that above syntax is not valid JSON, which is in this case not needed, as you only pass a JavaScript object in literal notation.

    Moreover, as x10 said in his comment, jQuery changes the ? in the callback query parameter to a unique function, which you should call, so don’t just copy-paste the above example, but replace parseResponse with the mentioned parameter.

    Update: the final thing you should change are the parameters to jQuery.getJSON: the syntax looks like:

    jQuery.getJSON( url, [ data ], [ success(data, textStatus, jqXHR) ] )
    

    So you should just pass your success function as the second or third parameter, not as part of an object (compare this to the general jQuery.ajax() function call):

    $.getJSON("***URL***.asmx/CheckAdvert?callback=?", function(data) { callback(data) });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain what the following javascript statement is doing? var default_hide =
Can someone please explain what the following function does. I am learning Asp.net MVC
Can someone please explain the following How was the first JDK release unit Tested?
Can someone please please explain to me why the following code works when I
Can someone wiser than I please explain to me why the following code segment
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
Can someone please explain me the following code snippet? value struct ValueStruct { int
Can someone please explain to me the following method? I don't quite understand what
Can someone please explain to me why the output from the following code is
can someone please explain to me the following JavaScript design pattern example and what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.