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

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

calling php function in jquery

I have one file json.js and one php function in php file .in json.js i want to check value returned by php function if value returned by function is 0 jquery should perform :$(':input').prop('disabled', true); otherwise nothing –

function loadJson (table, id) {
 $.get("json-object.php", {'table': table, 'id':id}, function (data) {
 console.log(data);
 $.each(data, function (k, v) {
 if ($('input[name="'+k+'"]').is('input[type="text"]')) {
 $('input[name="'+k+'"]').val(v);
 } 
 if($('select[name="'+k+'"]').val(v)){
 get_input_value(k,v); 
 } 
 if ($('input[name="'+k+'"]').is('input[type="checkbox"]')) {
 get_input_value(k,v);
 } 
 console.log(k+' ==> '+v);
 // Here I want to check condition of php function if value returned by fucntion is 0 it should perform :$(':input').prop('disabled', true); otherwise nothing //
 });
 }, 'json');
}

My php function:

function ronly($id) {
 //$id=$_POST['noces'];
 $sql = "SELECT COUNT(noces) FROM alterdetail WHERE noces = '$id'";
 $sql.=';';
 //echo "QUERY <br/>";
 //echo $sql;
 $res = mysql_query($sql);
 $row = mysql_fetch_array($res);
 if($row['COUNT(noces)'] > 0)
 { echo "you can not alter data";
 return 0;
 }
 else
 {
 echo " data new ";
 return 1;
 }
 } 

Answer*

Draft saved
Draft discarded
Cancel
2
  • what is sellform here ? process.php is the file where i have my php function . data type should be html ok . in success can i use my condition in place of function ? Commented Jun 20, 2012 at 8:11
  • #sellForm is a <form>. You can do: if(responseText === 0) { $(':input').prop('disabled', true); } instead the alert. If that's what you want. Commented Jun 20, 2012 at 8:19

default

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