Data loss in Ajax call

9 views
Skip to first unread message

Jacob Fullerton

unread,
Jan 16, 2017, 4:36:46 PM1/16/17
to Tethys Platform
Hey everyone,

So I've been finalizing the essential functionality of my latest app and I've run into a very strange bug in an ajax request. The exact problem I'm having is that only part of my data is arriving through the ajax request. Here's my code on the js side:

<javascript>
    var model = JSON.stringify(model_);
    var constant=JSON.stringify(constant_);
    var uflow=JSON.stringify(uflow_);
    var wells=JSON.stringify(wells_);
    var line_sink=JSON.stringify(linesink_);
    var head_line_sink=(JSON.stringify(headlinesink_));
    var res_line_sink=JSON.stringify(reslinesink_);
    var line_doublet_imp=JSON.stringify(linedoubletimp_);
    var line_sink_ditch=JSON.stringify(linesinkditch_);
    var polygon_inhom=JSON.stringify(polygoninhom_);
    var map_corners=JSON.stringify(map_window);

    $.ajax({
type: 'GET',
url: 'timml',
dataType: 'json',
data: {
            "model":model,
            "constant":constant,
            "uflow":uflow,
            "wells":wells,
            "line_sink":line_sink,
            "head_line_sink":head_line_sink,
            "res_line_sink":res_line_sink,
            "line_doublet_imp":line_doublet_imp,
            "line_sink_ditch":line_sink_ditch,
            "polygon_inhom":polygon_inhom,
            //  Map Information
            "map_corners":map_corners,
},
success: function (data){...}
    })

As an example of the data loss, I'll paste the 'head_line_sink' key that should be passed to the python:

'{"head_line_sink_0":{"coordinates":[[-12428480.903799545,4901909.994974004],[-12428396.852556359,4901814.660628697]],"head":"166","layers":"0","label":"HeadLineSink_3"},"head_line_sink_1":{"coordinates":[[-12429063.287896724,4901852.879142839],[-12428879.51621467,4901937.019544521]],"head":"170","layers":"0","label":"HeadLineSink_1"},"head_line_sink_2":{"coordinates":[[-12428669.159469629,4901926.927513991],[-12428496.10512046,4901915.062080977]],"head":"164","layers":"0","label":"HeadLineSink_12"},"head_line_sink_3":{"coordinates":[[-12428848.30875467,4902579.030911548],[-12428652.438869689,4902442.877454915]],"head":"162","layers":"0","label":"HeadLineSink_5"},"head_line_sink_4":{"coordinates":[[-12428645.272898287,4902438.100140648],[-12428635.71826975,4902280.44876981]],"head":"158","layers":"0","label":"HeadLineSink_17"},"head_line_sink_5":{"coordinates":[[-12428633.329612616,4902278.060112676],[-12428616.609012678,4902096.522170498]],"head":"166","layers":"0","label":"HeadLineSink_11"},"head_line_sink_6":{"coordinates":[[-12428621.386326946,4902091.744856231],[-12428485.232870314,4901917.372885455]],"head":"162","layers":"0","label":"HeadLineSink_15"},"head_line_sink_7":{"coordinates":[[-12428869.806668878,4901936.482142526],[-12428676.831935793,4901926.885330577]],"head":"166","layers":"0","label":"HeadLineSink_14"},"head_line_sink_8":{"coordinates":[[-12428554.503927201,4901422.920858735],[-12428315.63821381,4901360.815773253]],"head":"168","layers":"0","label":"HeadLineSink_2"},"head_line_sink_9":{"coordinates":[[-12429206.607324759,4901422.920858735],[-12429050.108816061,4901389.77199155]],"head":"168","layers":"0","label":"HeadLineSink_10"},"head_line_sink_10":{"coordinates":[[-12428320.4454121,4901632.993126204],[-12428303.69492814,4901365.593087521]],"head":"171","layers":"0","label":"HeadLineSink_9"},"head_line_sink_11":{"coordinates":[[-12429400.088552607,4901413.366230199],[-12429219.012381792,4901421.86366904]],"head":"158","layers":"0","label":"HeadLineSink_7"},"head_line_sink_12":{"coordinates":[[-12429039.401325386,4901389.479658861],[-12428838.979358897,4901425.241740354]],"head":"174","layers":"0","label":"HeadLineSink_8"},"head_line_sink_13":{"coordinates":[[-12428826.810840467,4901427.698173003],[-12428565.35558241,4901423.552704697]],"head":"160","layers":"0","label":"HeadLineSink_16"},"head_line_sink_14":{"coordinates":[[-12428389.695874048,4901805.274763251],[-12428322.804185208,4901640.288657921]],"head":"160","layers":"0","label":"HeadLineSink_6"},"head_line_sink_15":{"coordinates":[[-12429459.804980954,4901750.166886081],[-12429223.327924697,4901759.721514617]],"head":"164","layers":"0","label":"HeadLineSink_4"},"head_line_sink_16":{"coordinates":[[-12429217.323346134,4901764.737907475],[-12429072.066279605,4901845.811619027]],"head":"170","layers":"0","label":"HeadLineSink_13"}}'

*note: There should be 17 features as shown above, order is irrelevant

However, when I print the request.GET on the python side the data I have is the following: 
<python>
    get_data = request.GET
    print "Head_line_sink:"
    print get_data['head_line_sink']


Head_line_sink:
{"head_line_sink_0":{"coordinates":[[-12428480.903799545,4901909.994974004],[-12428396.852556359,4901814.660628697]],"head":"170","layers":"0","label":"HeadLineSink_1"},"head_line_sink_1":{"coordinates":[[-12428848.30875467,4902579.030911548],[-12428652.438869689,4902442.877454915]],"head":"160","layers":"0","label":"HeadLineSink_6"},"head_line_sink_2":{"coordinates":[[-12428645.272898287,4902438.100140648],[-12428635.71826975,4902280.44876981]],"head":"166","layers":"0","label":"HeadLineSink_14"},"head_line_sink_3":{"coordinates":[[-12428633.329612616,4902278.060112676],[-12428616.609012678,4902096.522170498]],"head":"158","layers":"0","label":"HeadLineSink_7"},"head_line_sink_4":{"coordinates":[[-12428621.386326946,4902091.744856231],[-12428485.232870314,4901917.372885455]],"head":"160","layers":"0","label":"HeadLineSink_16"},"head_line_sink_5":{"coordinates":[[-12428869.806668878,4901936.482142526],[-12428676.831935793,4901926.885330577]],"head":"170","layers":"0","label":"HeadLineSink_13"},"head_line_sink_6":{"coordinates":[[-12428669.159469629,4901926.927513991],[-12428496.10512046,4901915.062080977]],"head":"168","layers":"0","label":"HeadLineSink_2"},"head_line_sink_7":{"coordinates":[[-12429063.287896724,4901852.879142839],[-12428879.51621467,4901937.019544521]],"head":"168","layers":"0","label":"HeadLineSink_10"},"head_line_sink_8":{"coordinates":[[-12428554.503927201,4901422.920858735],[-12428315.63821381,4901360.815773253]],"head":"166","layers":"0","label":"HeadLineSink_11"},"head_line_sink_9":{"coordinates":[[-12429459.804980954,4901750.166886081],[-12429223.327924697,4901759.721514617]],"head":"171","layers":"0","label":"HeadLineSink_9"},"head_line_sink_10":{"coordinates":[[-12429400.088552607,4901413.366230199],[-12429219.012381792,4901421.86366904]],"head":"174","layers":"0","label":"HeadLineSink_8"},"head_line_sink_11":{"coordinates":[[-12429217.323346134,4901764.737907475],[-12429072.066279605,4901845.811619027]],"head":"162","layers":"0","label":"HeadLineSink_5"},"head_line_sink_12":{"c
 
ValueError: Unterminated string starting at: line 1 column 2020 (char 2019)
 
*note: Notice that the 12th feature object has been chopped. Additionally, my other key values that should follow the "head_line_sink" are not passed at all

I do not think that the error is related to the string size limit on the ajax request as I have gotten that error before when I deliberately passed a ridiculously large string via ajax (which I did to make sure that my string wasn't too long).

My code works fabulously for small datasets (like one or two features per layer) so I know that things can work properly! Just not sure why my data is getting chopped...

Any help on understanding this issue would be greatly appreciated! 

Jacob Fullerton

unread,
Jan 16, 2017, 4:40:17 PM1/16/17
to Tethys Platform
I guess I should also post the request URL:

[16/Jan/2017 21:39:58] "GET /apps/wellhead/timml/?model=%7B%22k%22%3A%222%2C6%2C4%22%2C%22zb%22%3A%22140%2C80%2C0%22%2C%22zt%22%3A%22165%2C120%2C60%22%2C%22c%22%3A%222000%2C20000%22%2C%22n%22%3A%220.3%2C0.25%2C0.3%22%2C%22nll%22%3A%220.2%2C0.25%22%7D&constant=%7B%22coordinates%22%3A%5B-12428163.998667294%2C4902610.985961657%5D%2C%22head%22%3A%22175%22%2C%22layer%22%3A%220%22%2C%22label%22%3A%22Constant_1%22%7D&uflow=%7B%7D&wells=%7B%22well_0%22%3A%7B%22coordinates%22%3A%5B-12428818.71093101%2C4901824.69867331%5D%2C%22Qw%22%3A%221000%22%2C%22rw%22%3A%220.3%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22Well_1%22%2C%22Num+Particles%22%3A%2210%22%2C%22zStart%22%3A%22150%22%7D%2C%22well_1%22%3A%7B%22coordinates%22%3A%5B-12428683.49141243%2C4902000.975885143%5D%2C%22Qw%22%3A%225000%22%2C%22rw%22%3A%220.3%22%2C%22layers%22%3A%222%22%2C%22label%22%3A%22Well_2%22%2C%22Num+Particles%22%3A%2210%22%2C%22zStart%22%3A%2230%22%7D%2C%22well_2%22%3A%7B%22coordinates%22%3A%5B-12428819.644869061%2C4901594.904172378%5D%2C%22Qw%22%3A%225000%22%2C%22rw%22%3A%220.3%22%2C%22layers%22%3A%221%2C2%22%2C%22label%22%3A%22maq_well%22%2C%22Num+Particles%22%3A%2210%22%2C%22zStart%22%3A%2230%22%7D%7D&line_sink=%7B%7D&head_line_sink=%7B%22head_line_sink_0%22%3A%7B%22coordinates%22%3A%5B%5B-12428480.903799545%2C4901909.994974004%5D%2C%5B-12428396.852556359%2C4901814.660628697%5D%5D%2C%22head%22%3A%22170%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_1%22%7D%2C%22head_line_sink_1%22%3A%7B%22coordinates%22%3A%5B%5B-12428848.30875467%2C4902579.030911548%5D%2C%5B-12428652.438869689%2C4902442.877454915%5D%5D%2C%22head%22%3A%22168%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_2%22%7D%2C%22head_line_sink_2%22%3A%7B%22coordinates%22%3A%5B%5B-12428645.272898287%2C4902438.100140648%5D%2C%5B-12428635.71826975%2C4902280.44876981%5D%5D%2C%22head%22%3A%22166%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_3%22%7D%2C%22head_line_sink_3%22%3A%7B%22coordinates%22%3A%5B%5B-12428633.329612616%2C4902278.060112676%5D%2C%5B-12428616.609012678%2C4902096.522170498%5D%5D%2C%22head%22%3A%22160%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_6%22%7D%2C%22head_line_sink_4%22%3A%7B%22coordinates%22%3A%5B%5B-12428621.386326946%2C4902091.744856231%5D%2C%5B-12428485.232870314%2C4901917.372885455%5D%5D%2C%22head%22%3A%22171%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_9%22%7D%2C%22head_line_sink_5%22%3A%7B%22coordinates%22%3A%5B%5B-12428869.806668878%2C4901936.482142526%5D%2C%5B-12428676.831935793%2C4901926.885330577%5D%5D%2C%22head%22%3A%22164%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_4%22%7D%2C%22head_line_sink_6%22%3A%7B%22coordinates%22%3A%5B%5B-12428669.159469629%2C4901926.927513991%5D%2C%5B-12428496.10512046%2C4901915.062080977%5D%5D%2C%22head%22%3A%22166%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_11%22%7D%2C%22head_line_sink_7%22%3A%7B%22coordinates%22%3A%5B%5B-12429063.287896724%2C4901852.879142839%5D%2C%5B-12428879.51621467%2C4901937.019544521%5D%5D%2C%22head%22%3A%22158%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_17%22%7D%2C%22head_line_sink_8%22%3A%7B%22coordinates%22%3A%5B%5B-12428554.503927201%2C4901422.920858735%5D%2C%5B-12428315.63821381%2C4901360.815773253%5D%5D%2C%22head%22%3A%22162%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_15%22%7D%2C%22head_line_sink_9%22%3A%7B%22coordinates%22%3A%5B%5B-12429459.804980954%2C4901750.166886081%5D%2C%5B-12429223.327924697%2C4901759.721514617%5D%5D%2C%22head%22%3A%22166%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_14%22%7D%2C%22head_line_sink_10%22%3A%7B%22coordinates%22%3A%5B%5B-12429217.323346134%2C4901764.737907475%5D%2C%5B-12429072.066279605%2C4901845.811619027%5D%5D%2C%22head%22%3A%22164%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_12%22%7D%2C%22head_line_sink_11%22%3A%7B%22coordinates%22%3A%5B%5B-12428389.695874048%2C4901805.274763251%5D%2C%5B-12428322.804185208%2C4901640.288657921%5D%5D%2C%22head%22%3A%22160%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_16%22%7D%2C%22head_line_sink_ HTTP/1.1" 500 30654

Jacob Fullerton

unread,
Jan 16, 2017, 4:43:55 PM1/16/17
to Tethys Platform
I'm currently investigating ways to shorten the URL as I think that this is the main issue even if the error is not being thrown. It's just behaving very strangely because I've found that if I attach a string of 2000+ characters at the very end of my URL my data gets passed through fine...which is not something I can explain at all.

Shawn Crawley

unread,
Jan 16, 2017, 4:44:06 PM1/16/17
to Jacob Fullerton, Tethys Platform
It seems that the URL that your request is generating is likely too long. See http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers. You'll likely need to change your request type from "GET" to "POST" and then send the data as a payload, rather than in the URL.

-Shawn

On Mon, Jan 16, 2017 at 2:40 PM Jacob Fullerton <jacob...@gmail.com> wrote:
I guess I should also post the request URL:

[16/Jan/2017 21:39:58] "GET /apps/wellhead/timml/?model=%7B%22k%22%3A%222%2C6%2C4%22%2C%22zb%22%3A%22140%2C80%2C0%22%2C%22zt%22%3A%22165%2C120%2C60%22%2C%22c%22%3A%222000%2C20000%22%2C%22n%22%3A%220.3%2C0.25%2C0.3%22%2C%22nll%22%3A%220.2%2C0.25%22%7D&constant=%7B%22coordinates%22%3A%5B-12428163.998667294%2C4902610.985961657%5D%2C%22head%22%3A%22175%22%2C%22layer%22%3A%220%22%2C%22label%22%3A%22Constant_1%22%7D&uflow=%7B%7D&wells=%7B%22well_0%22%3A%7B%22coordinates%22%3A%5B-12428818.71093101%2C4901824.69867331%5D%2C%22Qw%22%3A%221000%22%2C%22rw%22%3A%220.3%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22Well_1%22%2C%22Num+Particles%22%3A%2210%22%2C%22zStart%22%3A%22150%22%7D%2C%22well_1%22%3A%7B%22coordinates%22%3A%5B-12428683.49141243%2C4902000.975885143%5D%2C%22Qw%22%3A%225000%22%2C%22rw%22%3A%220.3%22%2C%22layers%22%3A%222%22%2C%22label%22%3A%22Well_2%22%2C%22Num+Particles%22%3A%2210%22%2C%22zStart%22%3A%2230%22%7D%2C%22well_2%22%3A%7B%22coordinates%22%3A%5B-12428819.644869061%2C4901594.904172378%5D%2C%22Qw%22%3A%225000%22%2C%22rw%22%3A%220.3%22%2C%22layers%22%3A%221%2C2%22%2C%22label%22%3A%22maq_well%22%2C%22Num+Particles%22%3A%2210%22%2C%22zStart%22%3A%2230%22%7D%7D&line_sink=%7B%7D&head_line_sink=%7B%22head_line_sink_0%22%3A%7B%22coordinates%22%3A%5B%5B-12428480.903799545%2C4901909.994974004%5D%2C%5B-12428396.852556359%2C4901814.660628697%5D%5D%2C%22head%22%3A%22170%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_1%22%7D%2C%22head_line_sink_1%22%3A%7B%22coordinates%22%3A%5B%5B-12428848.30875467%2C4902579.030911548%5D%2C%5B-12428652.438869689%2C4902442.877454915%5D%5D%2C%22head%22%3A%22168%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_2%22%7D%2C%22head_line_sink_2%22%3A%7B%22coordinates%22%3A%5B%5B-12428645.272898287%2C4902438.100140648%5D%2C%5B-12428635.71826975%2C4902280.44876981%5D%5D%2C%22head%22%3A%22166%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_3%22%7D%2C%22head_line_sink_3%22%3A%7B%22coordinates%22%3A%5B%5B-12428633.329612616%2C4902278.060112676%5D%2C%5B-12428616.609012678%2C4902096.522170498%5D%5D%2C%22head%22%3A%22160%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_6%22%7D%2C%22head_line_sink_4%22%3A%7B%22coordinates%22%3A%5B%5B-12428621.386326946%2C4902091.744856231%5D%2C%5B-12428485.232870314%2C4901917.372885455%5D%5D%2C%22head%22%3A%22171%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_9%22%7D%2C%22head_line_sink_5%22%3A%7B%22coordinates%22%3A%5B%5B-12428869.806668878%2C4901936.482142526%5D%2C%5B-12428676.831935793%2C4901926.885330577%5D%5D%2C%22head%22%3A%22164%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_4%22%7D%2C%22head_line_sink_6%22%3A%7B%22coordinates%22%3A%5B%5B-12428669.159469629%2C4901926.927513991%5D%2C%5B-12428496.10512046%2C4901915.062080977%5D%5D%2C%22head%22%3A%22166%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_11%22%7D%2C%22head_line_sink_7%22%3A%7B%22coordinates%22%3A%5B%5B-12429063.287896724%2C4901852.879142839%5D%2C%5B-12428879.51621467%2C4901937.019544521%5D%5D%2C%22head%22%3A%22158%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_17%22%7D%2C%22head_line_sink_8%22%3A%7B%22coordinates%22%3A%5B%5B-12428554.503927201%2C4901422.920858735%5D%2C%5B-12428315.63821381%2C4901360.815773253%5D%5D%2C%22head%22%3A%22162%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_15%22%7D%2C%22head_line_sink_9%22%3A%7B%22coordinates%22%3A%5B%5B-12429459.804980954%2C4901750.166886081%5D%2C%5B-12429223.327924697%2C4901759.721514617%5D%5D%2C%22head%22%3A%22166%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_14%22%7D%2C%22head_line_sink_10%22%3A%7B%22coordinates%22%3A%5B%5B-12429217.323346134%2C4901764.737907475%5D%2C%5B-12429072.066279605%2C4901845.811619027%5D%5D%2C%22head%22%3A%22164%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_12%22%7D%2C%22head_line_sink_11%22%3A%7B%22coordinates%22%3A%5B%5B-12428389.695874048%2C4901805.274763251%5D%2C%5B-12428322.804185208%2C4901640.288657921%5D%5D%2C%22head%22%3A%22160%22%2C%22layers%22%3A%220%22%2C%22label%22%3A%22HeadLineSink_16%22%7D%2C%22head_line_sink_ HTTP/1.1" 500 30654

--
You received this message because you are subscribed to the Google Groups "Tethys Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tethysplatfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tethysplatform/09af2671-c88a-4e1d-85a2-89483c8e970a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jacob Fullerton

unread,
Jan 16, 2017, 4:48:41 PM1/16/17
to Tethys Platform
Do you think it would be smarter to directly access my sessionStorage instead of passing data at all? I have considered doing that instead.

Jacob Fullerton

unread,
Jan 16, 2017, 5:15:49 PM1/16/17
to Tethys Platform, jacob...@gmail.com
Switching to POST made all the difference. Thanks @shawncrawley!
Reply all
Reply to author
Forward
0 new messages