Your Location is: Home > Php

HTML redraw with ajax issue in PHP project

From: Turkey View: 1358 ravenUSMC 

Question

I'm working on a PHP assignment and having trouble getting an ajax call to properly redraw. Everything almost works except I have this one line of code that keeps giving me errors:

$line .= '<input type="button" onclick="$j(this).attr(\'disabled\',true).val(\'Updating...\');xajax_save_message(' . $error . ',' . '$j(\'#error_' . $error_code . '\').val());return false;" id="save_button_' . $error_code . '" value="Save" />';

I think I have an escape character in the wrong place. Currently, the error message that I'm getting is:

XML Parsing Error: not well-formed
Location: http://127.0.0.1/dev/admin_eprescribing_error_messages.php
Line Number 1, Column 63:

The error occurs when I actually push the button to save. As I said, this is a PHP project which uses a library called Xajax to do ajax calls.

Any help would be great.

$j = "$"."j";
    $line .= '<td align="left">';
    $line.= <<<DELIMETER
    <input type="button" onclick="$j(this).attr('disabled',true).val('Updating...');xajax_save_message({$error_code},$j('#error_message{$error_code}').val());return false;" id="save_button_{$error_code}" value="Save" />;
    DELIMETER;
    $line .= '&nbsp';

Best answer

You should use

$j = "$"."j";
$line.= <<<DELIMETER
<input type="button" onclick="$j(this).attr('disabled',true).val('Updating...');xajax_save_message({$error},$j('#error_{$error_code}).val());return false;" id="save_button_{$error_code}" value="Save" />;
DELIMETER;