FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP/AJAX Problem
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP/AJAX Problem [message #170826] Tue, 30 November 2010 23:15 Go to next message
bruceaj is currently offline  bruceaj
Messages: 30
Registered: September 2010
Karma: 0
Member
My AJAX response from my PHP flashes briefly then goes away.

Appreciate it if someone can give me some suggestions on what I need
to do to correct this problem.

Thanks..

Bruce
Re: PHP/AJAX Problem [message #170827 is a reply to message #170826] Wed, 01 December 2010 00:11 Go to previous messageGo to next message
Magno is currently offline  Magno
Messages: 49
Registered: October 2010
Karma: 0
Member
On 11/30/2010 08:15 PM, bruceaj wrote:
> My AJAX response from my PHP flashes briefly then goes away.
>
> Appreciate it if someone can give me some suggestions on what I need
> to do to correct this problem.

Hard to guess anything without any code provided.
Please provide the minimum code needed to reproduce the issue.
Re: PHP/AJAX Problem [message #170828 is a reply to message #170826] Wed, 01 December 2010 00:17 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<aabb4728-afa5-462f-8d2f-052b42c4043f(at)p7g2000prb(dot)googlegroups(dot)com>,
bruceaj <bruceaj(at)bellsouth(dot)net> wrote:

> My AJAX response from my PHP flashes briefly then goes away.
>
> Appreciate it if someone can give me some suggestions on what I need
> to do to correct this problem.

What does "briefly flashes" mean? Not outside your bedroom window I hope.

A sensible problem description [1] and some context would help.

[1] One place I used to work at, there was one irritating person who
came into my office from time to time and said: "It doesn't work". My
usual response to him was "Have you been to the Doctor about it?". He
eventually got the point - please try to also.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP/AJAX Problem [message #170829 is a reply to message #170827] Wed, 01 December 2010 00:26 Go to previous messageGo to next message
bruceaj is currently offline  bruceaj
Messages: 30
Registered: September 2010
Karma: 0
Member
On Nov 30, 7:11 pm, Magno <marbar...@gmail.com> wrote:
> On 11/30/2010 08:15 PM, bruceaj wrote:
>
>> My AJAX response from my PHP flashes briefly then goes away.
>
>> Appreciate it if someone can give me some suggestions on what I need
>> to do to correct this problem.
>
> Hard to guess anything without any code provided.
> Please provide the minimum code needed to reproduce the issue.

Here is my Code. This is the call from my main routine

<input name="btnSearch" type="submit" id="btnSearch"
onclick="getData('results')", value="Submit Search" />

This is the function that makes a "Synchronous" call to APAX.. I'm
using Synchronous to try to debug my problem.

target points to the output area in my main routine, <div
id-'results'></div>
function getData(target) {
var serverPage = "getCensusData.php";
var parmStr = "lastname=Jul%";
var obj = document.getElementById(target);
processSJAXPost(serverPage, parmStr, obj);
}

Here is my SJAX call.
function processSJAXPost(serverpage, parmStr, obj) {

xmlhttp = getxmlhttp();
xmlhttp.open("POST", serverpage, false);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
xmlhttp.setRequestHeader("Content-length", parmStr.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(parmStr);

obj.innerHTML =
xmlhttp.responseText;;
}

My PHP routine is nothing but an single statement, <?php echo
"getData()"; ?>
Now, I'm getting a result from my PHP routine but it "flashs" and goes
away.

Thanks for the help..

Bruce
Re: PHP/AJAX Problem [message #170830 is a reply to message #170828] Wed, 01 December 2010 00:40 Go to previous messageGo to next message
bruceaj is currently offline  bruceaj
Messages: 30
Registered: September 2010
Karma: 0
Member
On Nov 30, 7:17 pm, Tim Streater <timstrea...@waitrose.com> wrote:
> In article
> <aabb4728-afa5-462f-8d2f-052b42c40...@p7g2000prb.googlegroups.com>,
>
>  bruceaj <bruc...@bellsouth.net> wrote:
>> My AJAX response from my PHP flashes briefly then goes away.
>
>> Appreciate it if someone can give me some suggestions on what I need
>> to do to correct this problem.
>
> What does "briefly flashes" mean? Not outside your bedroom window I hope.
>
> A sensible problem description [1] and some context would help.
>
> [1] One place I used to work at, there was one irritating person who
> came into my office from time to time and said: "It doesn't work". My
> usual response to him was "Have you been to the Doctor about it?". He
> eventually got the point - please try to also.
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

Briefly flashes means that the results of the echo statement in my php
routine, "flash" on my main page for less then a second.

Sorry for not posting the code in my first response. I know what you
mean with your dissertation. I was hoping the solution would be simple
and I wouldn't have to post code.

Thank you very much for your response. Hopefully the code I posted
will help...

Bruce
Re: PHP/AJAX Problem [message #170831 is a reply to message #170826] Wed, 01 December 2010 00:52 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/30/2010 6:15 PM, bruceaj wrote:
> My AJAX response from my PHP flashes briefly then goes away.
>
> Appreciate it if someone can give me some suggestions on what I need
> to do to correct this problem.
>
> Thanks..
>
> Bruce

PHP knows nothing about the browser end. PHP sends data to the browser;
if it only flashes, one of two things are happening:

1) The javascript is doing something odd - follow up in comp.lang.javascript
2) The html is invalid - try alt.html.

In either case - if the data gets to the browser, it is not a PHP
problem. PHP is server-side only.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP/AJAX Problem [message #170832 is a reply to message #170831] Wed, 01 December 2010 03:26 Go to previous messageGo to next message
bruceaj is currently offline  bruceaj
Messages: 30
Registered: September 2010
Karma: 0
Member
On Nov 30, 7:52 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 11/30/2010 6:15 PM, bruceaj wrote:
>
>> My AJAX response from my PHP flashes briefly then goes away.
>
>> Appreciate it if someone can give me some suggestions on what I need
>> to do to correct this problem.
>
>> Thanks..
>
>> Bruce
>
> PHP knows nothing about the browser end.  PHP sends data to the browser;
> if it only flashes, one of two things are happening:
>
> 1) The javascript is doing something odd - follow up in comp.lang.javascript
> 2) The html is invalid - try alt.html.
>
> In either case - if the data gets to the browser, it is not a PHP
> problem.  PHP is server-side only.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

That's true. My PHP is working fine. BUT, it takes two to tango! I
doubt that there are too many people who write ONLY PHP code. A lot
also work on the client side and I was hopping some of those could
give me some suggestions.

Thanks for the response..

Bruce
Re: PHP/AJAX Problem [message #170833 is a reply to message #170832] Wed, 01 December 2010 03:35 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/30/2010 10:26 PM, bruceaj wrote:
> On Nov 30, 7:52 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 11/30/2010 6:15 PM, bruceaj wrote:
>>
>>> My AJAX response from my PHP flashes briefly then goes away.
>>
>>> Appreciate it if someone can give me some suggestions on what I need
>>> to do to correct this problem.
>>
>>> Thanks..
>>
>>> Bruce
>>
>> PHP knows nothing about the browser end. PHP sends data to the browser;
>> if it only flashes, one of two things are happening:
>>
>> 1) The javascript is doing something odd - follow up in comp.lang.javascript
>> 2) The html is invalid - try alt.html.
>>
>> In either case - if the data gets to the browser, it is not a PHP
>> problem. PHP is server-side only.
>>
>
> That's true. My PHP is working fine. BUT, it takes two to tango! I
> doubt that there are too many people who write ONLY PHP code. A lot
> also work on the client side and I was hopping some of those could
> give me some suggestions.
>
> Thanks for the response..
>
> Bruce

Please see above. It doesn't matter how many people write in whatever
other languages. This is a PHP newsgroup, and where the PHP experts
hang out. If your PHP code is working, you're in the wrong group.
Please ask in a more appropriate newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP/AJAX Problem [message #170835 is a reply to message #170829] Wed, 01 December 2010 10:15 Go to previous messageGo to next message
Jeff North is currently offline  Jeff North
Messages: 58
Registered: November 2010
Karma: 0
Member
On Tue, 30 Nov 2010 16:26:43 -0800 (PST), in comp.lang.php bruceaj
<bruceaj(at)bellsouth(dot)net>
<7a800d5d-7bb8-4797-a7b6-92ce644f0d33(at)i25g2000prd(dot)googlegroups(dot)com>
wrote:

> | On Nov 30, 7:11 pm, Magno <marbar...@gmail.com> wrote:
> | > On 11/30/2010 08:15 PM, bruceaj wrote:
> | >
> | > > My AJAX response from my PHP flashes briefly then goes away.
> | >
> | > > Appreciate it if someone can give me some suggestions on what I need
> | > > to do to correct this problem.
> | >
> | > Hard to guess anything without any code provided.
> | > Please provide the minimum code needed to reproduce the issue.
> |
> | Here is my Code. This is the call from my main routine
> |
> | <input name="btnSearch" type="submit" id="btnSearch"
> | onclick="getData('results')", value="Submit Search" />

Is this button within a <form> element?

> | This is the function that makes a "Synchronous" call to APAX.. I'm
> | using Synchronous to try to debug my problem.
> |
> | target points to the output area in my main routine, <div
> | id-'results'></div>
> | function getData(target) {
> | var serverPage = "getCensusData.php";
> | var parmStr = "lastname=Jul%";
> | var obj = document.getElementById(target);
> | processSJAXPost(serverPage, parmStr, obj);

If so then do a return false; here.

> | }
> |
> | Here is my SJAX call.
> | function processSJAXPost(serverpage, parmStr, obj) {
> |
> | xmlhttp = getxmlhttp();
> | xmlhttp.open("POST", serverpage, false);
> | xmlhttp.setRequestHeader("Content-type", "application/x-www-form-
> | urlencoded");
> | xmlhttp.setRequestHeader("Content-length", parmStr.length);
> | xmlhttp.setRequestHeader("Connection", "close");
> | xmlhttp.send(parmStr);
> |
> | obj.innerHTML =
> | xmlhttp.responseText;;
> | }
> |
> | My PHP routine is nothing but an single statement, <?php echo
> | "getData()"; ?>
> | Now, I'm getting a result from my PHP routine but it "flashs" and goes
> | away.
> |
> | Thanks for the help..
> |
> | Bruce
Re: PHP/AJAX Problem [message #170836 is a reply to message #170835] Wed, 01 December 2010 10:40 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 12/1/2010 11:15 AM, Jeff North wrote:
> On Tue, 30 Nov 2010 16:26:43 -0800 (PST), in comp.lang.php bruceaj
> <bruceaj(at)bellsouth(dot)net>
> <7a800d5d-7bb8-4797-a7b6-92ce644f0d33(at)i25g2000prd(dot)googlegroups(dot)com>
> wrote:
>
>> | On Nov 30, 7:11 pm, Magno<marbar...@gmail.com> wrote:
>> |> On 11/30/2010 08:15 PM, bruceaj wrote:
>> |>
>> |> > My AJAX response from my PHP flashes briefly then goes away.
>> |>
>> |> > Appreciate it if someone can give me some suggestions on what I need
>> |> > to do to correct this problem.
>> |>
>> |> Hard to guess anything without any code provided.
>> |> Please provide the minimum code needed to reproduce the issue.
>> |
>> | Here is my Code. This is the call from my main routine
>> |
>> |<input name="btnSearch" type="submit" id="btnSearch"
>> | onclick="getData('results')", value="Submit Search" />
>
> Is this button within a<form> element?

Also:

<input name="btnSearch" type="submit" id="btnSearch"
onclick="getData('results')", value="Submit Search" />

What is that comma (,) doing after onclick="getData('results')" ?

And the closing tag /> indicates an XML file. What is the doctype?

Regards,
Erwin Moller


--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Re: PHP/AJAX Problem [message #170841 is a reply to message #170829] Wed, 01 December 2010 15:08 Go to previous messageGo to next message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma: 0
Junior Member
Am 01.12.2010 01:26, schrieb bruceaj:

> Here is my Code. This is the call from my main routine
>
> <input name="btnSearch" type="submit" id="btnSearch"
> onclick="getData('results')", value="Submit Search" />
^
Is this a typo?

As others already wrote: Here you have a submit button. So it does two
things, when clicked:

Calls the JavaScript function
*and*
submits the form (if it's within a form).

That triggers two requests, where I guess, the response of the
form-submit "overwrites" the response from the AJAX call.

Solution: either use a <input type="button" />, which wouldn't submit
the form. Or use your submit-button and return false from the click
handler to suppress the submitting of the form. But this makes only
sense, if you want a fallback in submitting the form, if JavaScript is
turned off or your JavaScript functions return a correct true or false,
depending whether the call succeeded or not.

> <div id-'results'></div>
^
Is this a typo? With this, I don't think, you would have an element with
the id "results".

Helmut
Re: PHP/AJAX Problem [message #170895 is a reply to message #170841] Sun, 05 December 2010 23:13 Go to previous messageGo to next message
bruceaj is currently offline  bruceaj
Messages: 30
Registered: September 2010
Karma: 0
Member
On Dec 1, 10:08 am, Helmut Chang <use...@helmutchang.at> wrote:
> Am 01.12.2010 01:26, schrieb bruceaj:
>
>> Here is my Code. This is the call from my main routine
>
>> <input name="btnSearch" type="submit" id="btnSearch"
>> onclick="getData('results')", value="Submit Search" />
>
>                                ^
>                                Is this a typo?
>
> As others already wrote: Here you have a submit button. So it does two
>
> things, when clicked:
>
> Calls the JavaScript function
> *and*
> submits the form (if it's within a form).
>
> That triggers two requests, where I guess, the response of the
> form-submit "overwrites" the response from the AJAX call.
>
> Solution: either use a <input type="button" />, which wouldn't submit
> the form. Or use your submit-button and return false from the click
> handler to suppress the submitting of the form. But this makes only
> sense, if you want a fallback in submitting the form, if JavaScript is
> turned off or your JavaScript functions return a correct true or false,
> depending whether the call succeeded or not.
>
>> <div id-'results'></div>
>
>           ^
> Is this a typo? With this, I don't think, you would have an element with
> the id "results".
>
> Helmut

I changed the button to a type button and all works fine

As of <div id='results"></div>, this is the target for my innerHTML
AJAX response..

Thanks...

Bruce
Re: PHP/AJAX Problem [message #170896 is a reply to message #170895] Sun, 05 December 2010 23:34 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 05/12/10 23:13, bruceaj wrote:
> On Dec 1, 10:08 am, Helmut Chang <use...@helmutchang.at> wrote:
>> Am 01.12.2010 01:26, schrieb bruceaj:
>>
>>> Here is my Code. This is the call from my main routine
>>
>>> <input name="btnSearch" type="submit" id="btnSearch"
>>> onclick="getData('results')", value="Submit Search" />
>>
>> ^
>> Is this a typo?
>>
>> As others already wrote: Here you have a submit button. So it does two
>>
>> things, when clicked:
>>
>> Calls the JavaScript function
>> *and*
>> submits the form (if it's within a form).
>>
>> That triggers two requests, where I guess, the response of the
>> form-submit "overwrites" the response from the AJAX call.
>>
>> Solution: either use a <input type="button" />, which wouldn't submit
>> the form. Or use your submit-button and return false from the click
>> handler to suppress the submitting of the form. But this makes only
>> sense, if you want a fallback in submitting the form, if JavaScript is
>> turned off or your JavaScript functions return a correct true or false,
>> depending whether the call succeeded or not.
>>
>>> <div id-'results'></div>
>>
>> ^
>> Is this a typo? With this, I don't think, you would have an element with
>> the id "results".
>>
>> Helmut
>
> I changed the button to a type button and all works fine
>
> As of <div id='results"></div>, this is the target for my innerHTML
> AJAX response..

I hope it's actually:

<div id='results'></div>

or:

<div id="results"></div>

and not really:

<div id='results"></div>

Rgds

Denis McMahon
Re: PHP/AJAX Problem [message #170900 is a reply to message #170895] Mon, 06 December 2010 09:07 Go to previous message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma: 0
Junior Member
Am 06.12.2010 00:13, schrieb bruceaj:

> As of<div id='results"></div>, this is the target for my innerHTML
> AJAX response..

Yes, I know ;). But you had:

<div id-'results'></div>
^

with a minus instead of an equal sign in your original posting.

Helmut
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: return value?
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 14:38:13 GMT 2024

Total time taken to generate the page: 0.02532 seconds