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 3998156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:29:26+00:00 2026-05-20T07:29:26+00:00

I can run this code in Android app (using PhoneGap adn jQuery Mobile) but

  • 0

I can run this code in Android app (using PhoneGap adn jQuery Mobile) but not on desktop browsers.
It gives me a syntax error in firebug for this line =

var TicketList = eval("(" + ajax.responseText + ")"); 

Here is the code

// JScript source code

// ran on body load
function doJsStuff()
{
    var ajax = AJAX();
    ajax.onreadystatechange = function () {
        if (ajax.readyState == 4) {
            var TicketList = eval("(" + ajax.responseText + ")");
            if (TicketList.ListCount > 0) {
            document.getElementById("opencount").innerHTML = TicketList.ListCount +" Open Tickets";
                for (Ticket in TicketList.Tickets) {
                // add stuff to DOM
                //AddTicketToList(TicketList.Tickets[Ticket]);
                }
            }
            else {
                document.getElementById("opencount").innerHTML = "All Tickets Reviewed";
                DisplayNoresults();
            }
        }
    }
    ajax.open("GET", "http://website.com/ListTicketsRequest.ashx?PageNumber=1&PageSize=1&Status=Open", true);
    ajax.send(null);
    //document.addEventListener("deviceready", onDeviceReady, false); 
    //event to check for PhoneGap
    //$('ul').listview('refresh');
    $('#mtickets').page();
    //showVars();
}

function AJAX()
{
    var xmlHttp;
    try
    {
        xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
    }
    return xmlHttp;
}

**TicketList is a variable in the JSon that comes across like this=

{"Tickets" : [{"TicketID": "1054","Category": "N/A","SubmittedUserID": "bob.thebuilder","ShortDescription": "test question QID:16668","CreationDate": "2/16/2011 12:24:19 PM","TicketStatus": "Open","LongDescription": "Something is wrong with this question I know I hve the right answer but it keeps telling me I'm wrong"},{"TicketID": "1053","Category": "Mission Support","SubmittedUserID": "dave","ShortDescription": "Make  courseware revisions","CreationDate": "2/16/2011 9:34:48 AM","TicketStatus": "Open","LongDescription": "Find help tickets generated by users for possible courseware update."}], "PageCount": "6", "ListCount": "11"}

Note about PhoneGap If you are trying to include phoengap functions in a place where the code may also be executed on in a browser make sure you only add the phone gap function with on “deviceready” or your browser will not render. Example:

function onload(){
        //event to check for PhoneGap
        document.addEventListener("deviceready", onDeviceReady, true);
}
...
function onDeviceReady() 
    {
        // Now PhoneGap API ready
        vibrate(90); // vib to ack pg ready
        $("a").click(function(event){
        vibrate(30); // add 30 sec vib to all links
        });         
    }
  • 1 1 Answer
  • 0 Views
  • 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-20T07:29:27+00:00Added an answer on May 20, 2026 at 7:29 am

    My immediate response would be to use jQuery’s getJSON method, since you’re aready using jQuery. jQuery’s AJAX provides a much broader base of browser compatibility. Also, every time you use eval(), a small baby somewhere cries.

    var url = "http://website.com/ListTicketsRequest.ashx?PageNumber=1&PageSize=1&Status=Open";
    
    $.getJSON(url ,function(TicketList){
        if (TicketList.ListCount > 0) {
            $("#opencount").html(TicketList.ListCount +" Open Tickets");
            for (Ticket in TicketList.Tickets) {
                ...
            }
        } else {
            $("#opencount").html("All Tickets Reviewed");
            DisplayNoresults();
        }
    });
    

    If this still doesn’t work for you, ensure that the JSON being returned is valid. But please stick to this method, and don’t use eval!!

    SIMPLIFIED UPDATE

    var url = "http://website.com/ListTicketsRequest.ashx?PageNumber=1&PageSize=1&Status=Open";
    $.getJSON(url ,function(AnyNameYouWant){
       alert(AnyNameYouWant.ListCount + " Open Tickets");
    });
    

    UPDATE USING ‘DATA’

    If your url becomes too long, you might begin to encounter problems. It is suggested to pass the url data via the data argument.

    var url = "http://website.com/ListTicketsRequest.ashx";
    var data = "PageNumber=1&PageSize=1&Status=Open";
    
    $.getJSON(url, data, function(AnyNameYouWant){
       alert(AnyNameYouWant.ListCount + " Open Tickets");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building my first mobile app using PhoneGap and jQuery Mobile, and I've run
This code is not working.. Can anyone help me out. when i had run
what behaviour can I expect when I run this code: do while(testA) { //
I can run tasks as part of our functional tests just fine using this
On windows, I can run my ruby script like this: > ruby myscript.rb but
This is a Java syntax question, but just for some background. Using android, I
I am trying to run to Android code using an AsyncTask . However it
I can run this command in SqlManager to detach the db ALTER DATABASE mydb
How can I run this on linux command line when my username has an
I can't run this function. It gives the error: ERROR at line 9: PL/SQL:

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.