This topic is locked

JS error with button

11/10/2011 4:47:28 PM
PHPRunner General questions
W
wildwally author

Need some help getting around this issue. I have a custom button with the following code:
Client Before:

var regexS = "[\\?&]editid1=([^&#]*)";

var regex = new RegExp( regexS );

var results = regex.exec( window.location.href );

params["edit"] = results[1];


Server:

$sql = "Update AE set JobStatus = '9' where AEID = '".$params["edit"]."'";
CustomQuery($sql);


Client After:

window.location.href="AE_Transfer_Requests_List.php";


The problem is the update changes a field on the page displayed. If I take the client after out and add it to the last section of client before I don't get any errors and the page redirects - although I have to reload the target page to see the record. What can I do differrently to get this button to flow through the process without any issues?

C
cgphp 11/10/2011

Not sure I understand what you mean. Is it a issue related to the query in the Server section ? Is AEID an int field type ?

W
wildwally author 11/10/2011

The issue i have is after the server updates the record. It doesn't redirect the page as instructed in the client after.
If I take the redirect code from the client after and use it in the client before the code works; however when redirected to the list page the newest results are not shown unless I reload again. Due to the server code taking place after my redirect. I'm assuming it has something to do with the sequence of events and the change taking place to the record while still on the page, because the three sections of code work independantly or rearranged as i just described.
This works but requires and additional manual refresh on the list page.
Client Before:

var regexS = "[\\?&]editid1=([^&#]*)";

var regex = new RegExp( regexS );

var results = regex.exec( window.location.href );

params["edit"] = results[1];
window.location.href="AE_Transfer_Requests_List.php";


Server:

$sql = "Update AE set JobStatus = '9' where AEID = '".$params["edit"]."'";
CustomQuery($sql);
C
cgphp 11/10/2011

In the Server section, enter the following code:

$sql = "Update AE set JobStatus = '9' where AEID = ".$params["edit"];

CustomQuery($sql);
W
wildwally author 11/10/2011



In the Server section, enter the following code:

$sql = "Update AE set JobStatus = '9' where AEID = ".$params["edit"];

CustomQuery($sql);



No change in outcome.
Is there a way to to get the server code to reload the page after executing the update? And bypassing the client after?

C
cgphp 11/10/2011

Try do debug your code.
At the end of the Client before enter the following code:

alert(params["edit"]);



Make sure that the params["edit"] is not empty. Enable firebug for further investigation.

W
wildwally author 11/10/2011



Try do debug your code.
At the end of the Client before enter the following code:

alert(params["edit"]);



Make sure that the params["edit"] is not empty. Enable firebug for further investigation.


The parameter is correct.
error given doesn't go to anything relavent to whats taking place. I have buttons looking at the status thats changing and I think that it might be giving the problem because I'm changing the status.
POST http://localhost:8085/buttonhandler.php200 OK

67msJSON.parse

throw new SyntaxError('JSON.parse');

C
cgphp 11/11/2011

Do you have some code in the "Javascript onload" event ? Try to comment out it and rebuild your project.