Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for Calling php function from jQuery

Current License: CC BY-SA 3.0

20 events
when toggle format what by license comment
Nov 13, 2014 at 7:07 vote accept Eddy
Nov 10, 2014 at 16:57 comment added ʰᵈˑ Would you be able to look in the console and see the request? Also in sm.php can you add echo print_r($_POST, true); and see if it's actually posting the functionname value?
Nov 10, 2014 at 16:48 comment added Eddy @hd, Your code doesn't call the function for some reason. It recognizes the SM.php file (if I change the name I get an error.) But the function isn't called, and if I change the name of it to something random, functionname: 'whateverrandom' I don't even get an error message. Is it something with my SM.php? Could you take a look at in in my question?
Nov 10, 2014 at 16:26 comment added ʰᵈˑ The entire php document being the one with the form, or the one with the saveTestObject?
Nov 10, 2014 at 16:23 comment added Eddy When I print the response, like this: console.log("success called " + response) from the jQuery success block, the entire php document is printed to the log. What am I doing wrong?
Nov 10, 2014 at 13:18 comment added ʰᵈˑ It shouldn't (jsfiddle.net/hhvac235/1) - Do you have the $("form").submit( function(event) { ?
Nov 10, 2014 at 13:18 comment added Eddy I put a console.log inside the jQuery's success block, and it's being called. But it's also being called if I change the functionname": "saveTasdfestObject" into any other string.
Nov 10, 2014 at 13:14 comment added Eddy I added it. It's showing right when the page renders, even before the button click.
Nov 10, 2014 at 13:07 comment added ʰᵈˑ Do you have <div id="reponse"></div> in your file?
Nov 10, 2014 at 13:06 comment added Eddy How do yon mean the div? I have the console open but there aren't any errors. Shouldn't the echo print to it? Also the saveTestObject function isn't doing the work it's supposed to do.
Nov 10, 2014 at 13:05 comment added ʰᵈˑ @Eddy - You have the div? Open up the console and see if there are any errors (there shouldn't be)
Nov 10, 2014 at 13:04 comment added Eddy @hdˑ, I have a echo "saveTestObject CALLED"; inside my saveTestObject function but I'm not seeing it called. Any idea?
Nov 10, 2014 at 12:59 comment added ʰᵈˑ Modified post for you Eddy. @Steve that's been dealt with the edit, thanks!
Nov 10, 2014 at 12:58 history edited hdˑ CC BY-SA 3.0
added 951 characters in body
Nov 10, 2014 at 12:55 comment added Eddy @hdˑthanks, but could you add a complete example of the html file? I'm new to PHP / jQuery.
Nov 10, 2014 at 12:54 comment added ʰᵈˑ Simply listen for the button click. $("form").submit( function() {
Nov 10, 2014 at 12:54 comment added Steve I imagine that the form inputs are not just for fun - though the OP will need to confirm
Nov 10, 2014 at 12:53 comment added ʰᵈˑ Have a trigger. Anything. What do you want your trigger to be?
Nov 10, 2014 at 12:52 comment added Eddy OK but how do I call this ajax from my html form?
Nov 10, 2014 at 12:51 history answered hdˑ CC BY-SA 3.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /