Error by parsing selected Panel index in JQuery UI Tabs

I'm trying to get the index of the selected panel from my Jquery UI Tab. I got following JS - Snippet:

function getSelectedPanel(){
     var values = new Object();
     values.activepanel =  $("#tabs").tabs( "option", "active" );
     var json = JSON.stringify(values);
     return json;
}

After that, I'm using this value in my Java - Code like this:

public String checkselectedPanel(json) {

    JSONObject values = (JSONObject) new JSONParser().parse(json);
    String activepanel = (String)values.get("activepanel");

     // ...
}

Everythime I get an exception despite the variable "activepanel" is filled with values, I could see it by debugging. I also tried to parse the value into an Integer, with the same result.

Answers


Try this:

function getSelectedPanel(){
 var values = new Object();
 values.activepanel =  String($("#tabs").tabs( "option", "active" ));
 var json = JSON.stringify(values);
 return json;

}

Your code in Java:

public String checkselectedPanel(json) {

JSONObject values = (JSONObject) new JSONParser().parse(json);
String activepanel = (String)values.get("activepanel");

 // do stuff

}

Tried it myself, seems to work, please post your exception next time as well.


Need Your Help

Async method doesnt continue to following code

c# asynchronous async-await

I wanna create some nested folders the object i m sending if have parent id when i debug it after await it act like break its not following next code line what can i do i couldnt find any solution on

Extension of array with Elements conforming a protocol in swift 2.0

generics swift2 swift-extensions

i'm trying to create an extension for the Array struct in order to add methods just if the contained objects conforms to a particular protocol, but i'm having strange behaviors when i try to access...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.