Akash Kumar
Akash Kumar

Reputation: 642

Error in Loading a php page through JQuery

I used this JQUERY code module for some purpose

$("#notice").show().load('update.php?first=1&institute='+sch+'&institute_code='+code,function(data,statusTxt,xhr) {
     $('#notice').show().html(data);}
    });

update.php?first=1&institute='+sch+'&institute_code='+code in the above code to be loaded but its not working as it should work

On update.php I used this code

echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];exit;

and the output i got is

http://localhost/teach/index/update.php?first=1&institute=Delhi

While it should be

http://localhost/teach/index/update.php?first=1&institute=Delhi&institute_code=441

&institute_code=441 part is missing,
where am i making mistake? I know its a silly mistake but i am wasted of searching that mistake.

Upvotes: 0

Views: 48

Answers (2)

user3121106
user3121106

Reputation: 1

This is usually where I find the problem when data is posting properly also make sure you have the code association proper, to assign the correct database properly to the url bar.

/Edit/ Try this:

$("#notice").show().load('update.php?first=1&institute='+sch+'&institute_code='+code,function(data,statusTxt,xhr) {
     $('#notice').show().html(data);}
    );

/Edit/

Upvotes: 0

Satpal
Satpal

Reputation: 133403

  1. Pass JSON object it more clear.
  2. Also as you are using load() you don't need to set data using .html()
  3. Use .show() in the callback method only

Code

$("#notice").load('update.php', {
        'first': 1,
        'institute': sch,
        'institute_code': code
    }, function (data, statusTxt, xhr) {
        $('#notice').show();
    });

Upvotes: 3

Related Questions