JQuery .get new url is not updating the page

68 views
Skip to first unread message

furqanmlk

unread,
May 18, 2012, 2:52:00 PM5/18/12
to django...@googlegroups.com
Hi there,

I implemented the JQuery to get the data from Database server and display in the form of table on the page when user click one of the DOM element.
I tried ,

JQuery Code:
$.get("RunId_TestCases",{Variable:Value},function(data){
                       
                       
                        Passed_TestCases = data['Data1'];
                        Failed_TestCases = data['Data2'];
                        //window.location.hash = this.url
                       //window.location.assign(this.url)

});

View.py
def RunId_TestCases(request)

    RunId = request.GET.get('ClickedRunId','')
   
    #Some python Code to process data
    results = {Data1:foo1,Data2:foo2}
    json = simplejson.dumps(results)
   return HttpResponse(json, mimetype='application/json')

url.py
url(r'^Home/.*/RunId_TestCases/$', RunId_TestCases)

using window.location browser url gets changed but page goes to empty page with data values.


Can you please help to solve this issue.

Lee Hinde

unread,
May 18, 2012, 7:52:20 PM5/18/12
to django...@googlegroups.com
On May 18, 2012, at 11:52 AM, furqanmlk wrote:

Hi there,

I implemented the JQuery to get the data from Database server and display in the form of table on the page when user click one of the DOM element.
I tried ,

JQuery Code:
$.get("RunId_TestCases",{Variable:Value},function(data){
                       
                       
                        Passed_TestCases = data['Data1'];
                        Failed_TestCases = data['Data2'];
                        //window.location.hash = this.url
                       //window.location.assign(this.url)


not knowing anything about the page, but you want something more like:

$("#ID_FOR_THE_FIELD").val(data['Data1']);

Furqan Malik

unread,
May 18, 2012, 11:24:40 PM5/18/12
to django...@googlegroups.com
Thanks for the reply,

You misunderstood my question.


Passed_TestCases = data['Data1'];
Failed_TestCases = data['Data2'];
These values are fine, I am using them to create the table.

My question is once these values come from view.py, I want to change the browser url so that url can be send to others.

 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Lee Hinde

unread,
May 19, 2012, 10:49:11 AM5/19/12
to django...@googlegroups.com
On May 18, 2012, at 8:24 PM, Furqan Malik wrote:

Thanks for the reply,

You misunderstood my question.

Passed_TestCases = data['Data1'];
Failed_TestCases = data['Data2'];
These values are fine, I am using them to create the table.

My question is once these values come from view.py, I want to change the browser url so that url can be send to others.


Furqan Malik

unread,
May 23, 2012, 11:23:21 AM5/23/12
to django...@googlegroups.com
Thank you so much Lee,

I am able to change the url but when i copy and past that url to new browser, it opens parent page.

Any help?

Kurtis Mullins

unread,
May 23, 2012, 12:54:11 PM5/23/12
to django...@googlegroups.com
I'm not sure of the use-case on this but you could possibly take the
following approach:

1. Get your dynamic page via AJAX with some given query
2. Modify the URL to match the query
3. When a user accesses the same page with the given query
(my/page/?foo=bar) then they'll see the same thing

Of course this will probably require modifying your view to accept queries.

Furqan Malik

unread,
May 23, 2012, 1:20:59 PM5/23/12
to django...@googlegroups.com
Thanks Kurtis,

1. Get your dynamic page via AJAX with some given query
Here is work flow,
a: when user clicks on "Result" button on the main menu,
the table is displayed in which first column is  "IDs".
and url becomes http://127.0.0.1:8080/Home/Search/

Furqan Malik

unread,
May 23, 2012, 1:28:04 PM5/23/12
to django...@googlegroups.com
Thanks Kurtis,

1. Get your dynamic page via AJAX with some given query
Here is work flow,
a: when user clicks on "Result" button on the main menu,
    the table is displayed in which first column is  "IDs".
    and url becomes http://127.0.0.1:8080/Home/Search/

b: when user clicks on any of the "IDs" on the table id results is displayed
    and url becomes http://127.0.0.1:8080/Home/Search/#RunId_TestCases%3FClickedRunId%3DThu-      May-17-11%253A32%253A21-2012

Here is what I am using Jquery
$.get("RunId_TestCases",{ClickedRunId:ClickedRunId},function(data){

      window.location.hash = encodeURIComponent(this.url);
       ShwowTable(data[results]);
});

Url is getting changed with contents changed but, that changed url can not be used again to get the same content.

2:Modify the URL to match the query
 I think, this step is missing .
To do this step, should I parse the new url and read id and run $.get function again?

Regards,
 
On Wed, May 23, 2012 at 12:54 PM, Kurtis Mullins <kurtis....@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages