0

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.

1
  • Just a guess: maybe sch value ("Delhi") is not just this literal exactly but contains a new line character? Commented Feb 2, 2014 at 22:15

2 Answers 2

3
  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();
    });
Sign up to request clarification or add additional context in comments.

3 Comments

thanks but First line of this code is showing error link of error image
@AkashKumar, My bad missed a comma after 'update.php'. Updated answer
Yes thanks, It worked very well with a minor change i.e. Delete the very last curly braces. Otherwise worked fine
0

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/

3 Comments

Till time, no database connection part came into existence in my problem, its just JQuery part
I see now you are only telling the it to post data and not the the rest of the data. Are you sure you have all the spelling and syntax correct elsewhere.
Yes all spelling are correct actually error was in sending a string with white spaces in url but now, i send the data using POST

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.