ExtJS Error: invalid label error while using ScriptTagProxy for JSON data in Paging Grid Example

You can also read this post if you are getting above error while using ScriptTagProxy.

With little bit modification i was trying to use Paging Grid Example from ExtJS. And that where i was getting following error:

invalid label
    {"success":true,"totalCount":

Actually it was not filling my grid, while examining with firebug i got above error. After banging my head over internet i found the reason ;).
Actually it is using ScriptTagProxy to get json data from server. I was sending pure json from server which is not the correct way. ScriptTagProxy sends a url parameter called “callback” which is function name. You need to take this param and form a parameter call. For example callback=fun1 is comming from server, then what you need to do is enclose your json with fun1(yourJSON) call.
like:
fun1({—-your json—-});

Following is an example of ASP.Net code for it:

 String json_string= //"some json here";
 String callback_function_name= Request.Params.Get("callback");
 String response_string = "";
 if (!String.IsNullOrEmpty(callback_function_name))
 {
 response_string = callback_function_name + "(" + json_string + ")";
 }
 else
 {
 response_string = json_string;
 }
 Response.Write(response_string);

you can see the difference of data comming from server for Paging Grid Example. Open following two url:

http://extjs.com/forum/topics-browse-remote.php
http://www.extjs.com/forum/topics-browse-remote.php?callback=fun_1

After examining the data on your browser you will see that, first url is giving pure json, while second one is giving json enclosed in fun_1() function call. ScriptTagProxy is expecting the second data not the pure json one.

If you have any suggestions please feel free to comment.

Advertisements
Published in: on December 2, 2009 at 7:47 pm  Comments (6)  
Tags: , , ,

The URI to TrackBack this entry is: https://indiandeve.wordpress.com/2009/12/02/extjs-error-invalid-label-error-while-using-scripttagproxy-for-json-data-in-paging-grid-example/trackback/

RSS feed for comments on this post.

6 CommentsLeave a comment

  1. Thanks,…you save me lot of time.

  2. Thank you kindly you saved me hours of frustration and trouble in working with extJS.

    Cheers,
    Alex

  3. thank you very much. i have been freaking out of this problem. i nearly going to brake my laptop. why do not they explain what they are doing while they give sample of usage. do we need to be pro or some other!!! any way, thank you very much again…

  4. THANK U VERY MUCH. it was gonna be a big trouble for me if i couldt find the solution here.
    if someone works with jsp and having the same trouble:

    String json_string = //”some json here”;
    String callback_function_name = request.getParameter(“callback”);
    String response_string = “”;
    if (!””.equals(callback_function_name)) {
    response_string = callback_function_name + “(” + json_string + “)”;
    } else {
    response_string = json_string;
    }
    out.println(response_string);

  5. Thanks ……
    🙂
    you save my lots of time

  6. Thanks …… 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: