[jQuery] [Autocomplete] modify URL at runtime
Hi, I'm using the autocomplete plugin like that in the ready() event : $(#ctl00_body_txtSearch).autocomplete(Autocomplete_GetArts.ashx) .setOptions({ width: 220px }); However I need to be able to change the URL (to add a bunch of query parameters) based on the values of some radio buttons and select boxes, which should be passed to the server page. How can I modify the URL before the AJAX call is made ? Is there an event I can use ? Thanks
[jQuery] Re: modify URL at runtime
I should have searched a little bit more, sorry. Answer is in that post : http://groups.google.com/group/jquery-en/browse_thread/thread/f5668aa46f07014a/cd60970334579d93?lnk=gstq=autocomplete#cd60970334579d93 On Oct 13, 5:31 pm, graphicsxp graphic...@googlemail.com wrote: Hi, I'm using the autocomplete plugin like that in the ready() event : $(#ctl00_body_txtSearch).autocomplete(Autocomplete_GetArts.ashx) .setOptions({ width: 220px }); However I need to be able to change the URL (to add a bunch of query parameters) based on the values of some radio buttons and select boxes, which should be passed to the server page. How can I modify the URL before the AJAX call is made ? Is there an event I can use ? Thanks
[jQuery] Re: issue with ajax function
This should only be set if your webservice expects the input parameter in JSON format as well, and not only the response is JSON. Is this the case? Yes, I thought that too. I've removed the contentType parameter. In this case the webservice is reached. But when the AJAX call returns I get the error 'parseerror' . The webservice method looks like : [WebMethod] public string GetPublication(String pText) { String result = ; result = @{results: [ { id: 4, value: guardian.co.uk } ]}; return result; } On 30 jan, 09:30, Beres Botond boton...@gmail.com wrote: A parameter has to be key=value, in some form, otherwise how is it identified? contentType: application/json; charset=utf-8, This should only be set if your webservice expects the input parameter in JSON format as well, and not only the response is JSON. Is this the case? How does the code of your webservice look like? (the part which gets the input parameter) On Jan 29, 6:50 pm, graphicsxp graphic...@googlemail.com wrote: Thanks.. I tried that but I'm getting an error before the webservice is reached : Invalid JSON primitive: pText. Like I said, my webservice's method expects a string, not a JSON key- value pair. I'd be surprised if we can't pass a simple string to a webservice ? On 29 jan, 16:24, MorningZ morni...@gmail.com wrote: Right from the docshttp://docs.jquery.com/Ajax/jQuery.ajax#options Object must be Key/Value pairs something that data: pText=some text is not (it's a string) so with that pointed out, try $.ajax({ url: Publication.asmx/GetPublication, data: { pText: some text }, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); On Jan 29, 10:58 am, graphicsxp graphic...@googlemail.com wrote: Hi, I'm trying to send a string to my webservice. The method I call expects a string parameter and returns a string of JSON data. I've tried this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); in which case I get the following error and the webservice is not even reached : Invalid JSON primitive: pText and this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, dataType: json, }); in which case the webservice is reached but then when the ajax call returns I get the following error : parseerror What do i need to do to fix this ? Thanks
[jQuery] Re: issue with ajax function
Well the reponseText property of the XHR object contains : ?xml version=1.0 encoding=utf-8? string xmlns=http://tempuri.org/;{results: [ { id: 4, value: guardian.co.uk } ]}/string that's what the webservice returns. Since dataType of my jquery ajax method is set to 'json', this should be interpreted as json data. On 30 jan, 11:14, Beres Botond boton...@gmail.com wrote: So the AJAX call actually returns some result now? If you alert() the result, before trying to do anything with it, what do you get? On Jan 30, 11:35 am, graphicsxp graphic...@googlemail.com wrote: This should only be set if your webservice expects the input parameter in JSON format as well, and not only the response is JSON. Is this the case? Yes, I thought that too. I've removed the contentType parameter. In this case the webservice is reached. But when the AJAX call returns I get the error 'parseerror' . The webservice method looks like : [WebMethod] public string GetPublication(String pText) { String result = ; result = @{results: [ { id: 4, value: guardian.co.uk } ]}; return result; } On 30 jan, 09:30, Beres Botond boton...@gmail.com wrote: A parameter has to be key=value, in some form, otherwise how is it identified? contentType: application/json; charset=utf-8, This should only be set if your webservice expects the input parameter in JSON format as well, and not only the response is JSON. Is this the case? How does the code of your webservice look like? (the part which gets the input parameter) On Jan 29, 6:50 pm, graphicsxp graphic...@googlemail.com wrote: Thanks.. I tried that but I'm getting an error before the webservice is reached : Invalid JSON primitive: pText. Like I said, my webservice's method expects a string, not a JSON key- value pair. I'd be surprised if we can't pass a simple string to a webservice ? On 29 jan, 16:24, MorningZ morni...@gmail.com wrote: Right from the docshttp://docs.jquery.com/Ajax/jQuery.ajax#options Object must be Key/Value pairs something that data: pText=some text is not (it's a string) so with that pointed out, try $.ajax({ url: Publication.asmx/GetPublication, data: { pText: some text }, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); On Jan 29, 10:58 am, graphicsxp graphic...@googlemail.com wrote: Hi, I'm trying to send a string to my webservice. The method I call expects a string parameter and returns a string of JSON data. I've tried this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); in which case I get the following error and the webservice is not even reached : Invalid JSON primitive: pText and this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, dataType: json, }); in which case the webservice is reached but then when the ajax call returns I get the following error : parseerror What do i need to do to fix this ? Thanks
[jQuery] issue with ajax function
Hi, I'm trying to send a string to my webservice. The method I call expects a string parameter and returns a string of JSON data. I've tried this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); in which case I get the following error and the webservice is not even reached : Invalid JSON primitive: pText and this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, dataType: json, }); in which case the webservice is reached but then when the ajax call returns I get the following error : parseerror What do i need to do to fix this ? Thanks
[jQuery] Re: issue with ajax function
Thanks.. I tried that but I'm getting an error before the webservice is reached : Invalid JSON primitive: pText. Like I said, my webservice's method expects a string, not a JSON key- value pair. I'd be surprised if we can't pass a simple string to a webservice ? On 29 jan, 16:24, MorningZ morni...@gmail.com wrote: Right from the docshttp://docs.jquery.com/Ajax/jQuery.ajax#options Object must be Key/Value pairs something that data: pText=some text is not (it's a string) so with that pointed out, try $.ajax({ url: Publication.asmx/GetPublication, data: { pText: some text }, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); On Jan 29, 10:58 am, graphicsxp graphic...@googlemail.com wrote: Hi, I'm trying to send a string to my webservice. The method I call expects a string parameter and returns a string of JSON data. I've tried this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, contentType: application/json; charset=utf-8, dataType: json, }); in which case I get the following error and the webservice is not even reached : Invalid JSON primitive: pText and this way : $.ajax({ url: Publication.asmx/GetPublication, data: pText=some text, type: POST, dataType: json, }); in which case the webservice is reached but then when the ajax call returns I get the following error : parseerror What do i need to do to fix this ? Thanks
[jQuery] Re: weird issue with ready event
Thanks for the tip. That didn't do anything though. I've tried $(pop).load(fn) and $(pop)._load(fn) as there seems to be two functions called load (one relates to AJAX). Anyway, I still can't get this to work. On 16 jan, 17:14, Ricardo Tomasi ricardob...@gmail.com wrote: I've seen this before, it seems the 'ready' doesn't fire on opened windows or frames, you have to use $(pop).load(fn) instead. On Jan 16, 1:11 pm, graphicsxp graphic...@googlemail.com wrote: Hello, I'm trying to set the html content of a DIV (id='list') which sits in a page opened with window.open : var pop = window.open(PrintList.aspx); $(pop.document).ready(function() { $(#list, pop.document).html(hello); }); As you can see, the string 'hello' should be written to the DIV once the page is loaded. Yet the first time I execute this script the string is never written. If I close the new window and I execute the script again, it will work. It's only the first time I execute it how weird.. Does anyone know why ? Thanks
[jQuery] Re: weird issue with ready event
actually it does work in Firefox ! The problem is in IE (7.0). Any idea ? On 19 jan, 10:46, graphicsxp graphic...@googlemail.com wrote: Thanks for the tip. That didn't do anything though. I've tried $(pop).load(fn) and $(pop)._load(fn) as there seems to be two functions called load (one relates to AJAX). Anyway, I still can't get this to work. On 16 jan, 17:14, Ricardo Tomasi ricardob...@gmail.com wrote: I've seen this before, it seems the 'ready' doesn't fire on opened windows or frames, you have to use $(pop).load(fn) instead. On Jan 16, 1:11 pm, graphicsxp graphic...@googlemail.com wrote: Hello, I'm trying to set the html content of a DIV (id='list') which sits in a page opened with window.open : var pop = window.open(PrintList.aspx); $(pop.document).ready(function() { $(#list, pop.document).html(hello); }); As you can see, the string 'hello' should be written to the DIV once the page is loaded. Yet the first time I execute this script the string is never written. If I close the new window and I execute the script again, it will work. It's only the first time I execute it how weird.. Does anyone know why ? Thanks
[jQuery] Re: weird issue with ready event
Here's exactly the code I wrote : var pop = window.open(PrintList.aspx); if ($.browser.msie) { $(pop.document).ready(function() { $(#list, pop.document).html('hello'); }); } else { $(pop).load(function() { $(#list, pop.document).html('hello'); }); } As you can see I have to use a different event for IE 7.0 and other broswers (that being FF 3.0 as I don't have any other browsers installed on my PC) In FF, it is working as expected. However in IE, the first time that code is called, the popup is opened but the ready event is not fired. If I close the popup, and trigger that code again, the ready is then fired ! And it works for all the following attempts, until I close my main window and I try again : same behaviour, ready not fired the first time the popup is opened but then works after that. This is really strange, if someone has an answer to this issue, please shed some light on this ! Thanks On 19 jan, 10:54, graphicsxp graphic...@googlemail.com wrote: actually it does work in Firefox ! The problem is in IE (7.0). Any idea ? On 19 jan, 10:46, graphicsxp graphic...@googlemail.com wrote: Thanks for the tip. That didn't do anything though. I've tried $(pop).load(fn) and $(pop)._load(fn) as there seems to be two functions called load (one relates to AJAX). Anyway, I still can't get this to work. On 16 jan, 17:14, Ricardo Tomasi ricardob...@gmail.com wrote: I've seen this before, it seems the 'ready' doesn't fire on opened windows or frames, you have to use $(pop).load(fn) instead. On Jan 16, 1:11 pm, graphicsxp graphic...@googlemail.com wrote: Hello, I'm trying to set the html content of a DIV (id='list') which sits in a page opened with window.open : var pop = window.open(PrintList.aspx); $(pop.document).ready(function() { $(#list, pop.document).html(hello); }); As you can see, the string 'hello' should be written to the DIV once the page is loaded. Yet the first time I execute this script the string is never written. If I close the new window and I execute the script again, it will work. It's only the first time I execute it how weird.. Does anyone know why ? Thanks
[jQuery] Re: weird issue with ready event
thanks for helping. It turns out I was still on 1.2.6, so i've installed 1.3 but that didn't fix my problem. Actually it brought more issues as I've noticed a few new bugs in my application. I'm rolling back to 1.2 ! On 19 jan, 11:50, Sergei yatse...@gmail.com wrote: I had a similar problem today in MSIE7 with 1.3:http://groups.google.com/group/jquery-en/browse_thread/thread/e4d9128... Look into this:http://dev.jquery.com/changeset/6120 It solved my problem. On Jan 19, 7:21 pm, graphicsxp graphic...@googlemail.com wrote: Here's exactly the code I wrote : var pop = window.open(PrintList.aspx); if ($.browser.msie) { $(pop.document).ready(function() { $(#list, pop.document).html('hello'); }); } else { $(pop).load(function() { $(#list, pop.document).html('hello'); }); } As you can see I have to use a different event for IE 7.0 and other broswers (that being FF 3.0 as I don't have any other browsers installed on my PC) In FF, it is working as expected. However in IE, the first time that code is called, the popup is opened but the ready event is not fired. If I close the popup, and trigger that code again, the ready is then fired ! And it works for all the following attempts, until I close my main window and I try again : same behaviour, ready not fired the first time the popup is opened but then works after that. This is really strange, if someone has an answer to this issue, please shed some light on this ! Thanks On 19 jan, 10:54, graphicsxp graphic...@googlemail.com wrote: actually it does work in Firefox ! The problem is in IE (7.0). Any idea ? On 19 jan, 10:46, graphicsxp graphic...@googlemail.com wrote: Thanks for the tip. That didn't do anything though. I've tried $(pop).load(fn) and $(pop)._load(fn) as there seems to be two functions called load (one relates to AJAX). Anyway, I still can't get this to work. On 16 jan, 17:14, Ricardo Tomasi ricardob...@gmail.com wrote: I've seen this before, it seems the 'ready' doesn't fire on opened windows or frames, you have to use $(pop).load(fn) instead. On Jan 16, 1:11 pm, graphicsxp graphic...@googlemail.com wrote: Hello, I'm trying to set the html content of a DIV (id='list') which sits in a page opened with window.open : var pop = window.open(PrintList.aspx); $(pop.document).ready(function() { $(#list, pop.document).html(hello); }); As you can see, the string 'hello' should be written to the DIV once the page is loaded. Yet the first time I execute this script the string is never written. If I close the new window and I execute the script again, it will work. It's only the first time I execute it how weird.. Does anyone know why ? Thanks- Hide quoted text - - Show quoted text -
[jQuery] weird issue with ready event
Hello, I'm trying to set the html content of a DIV (id='list') which sits in a page opened with window.open : var pop = window.open(PrintList.aspx); $(pop.document).ready(function() { $(#list, pop.document).html(hello); }); As you can see, the string 'hello' should be written to the DIV once the page is loaded. Yet the first time I execute this script the string is never written. If I close the new window and I execute the script again, it will work. It's only the first time I execute it how weird.. Does anyone know why ? Thanks