Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assist request for onclick event to trigger ajax call?

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
US
I'm trying to modify a simple html checkbox input item so when the user clicks the checkbox the logic calls a function which invokes an ajax call to a server program.
I've included a short snippet below:
Using alerts I've proven that the onClick event is triggered and (at one time) the javascript function was executing. But the $.ajax call to the server isn't happening.
At this point using the chrome browser and its inspection debugging function the console complains that the referenced function (Func1) is undefined.
Hopefully some guru(s) can provide some guidance so I can get this (supposedly) simple routine functional.
Thanks


<input name="checkbox1" type="checkbox" id="checkbox1" onclick="Func1($field1,field2);" /><br />

<script>
function Func1(field1, field2) {
$.ajax({
type: "POST",
url: "Alter-Checkbox.php",
data: { field1: field1, field2: field2 },
datatype: 'json',
cache: 'false',
});
}
</script>

test.php:61 Uncaught ReferenceError: Func1 is not defined
at HTMLInputElement.onclick (
[ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top